Dev Tutorial

Environment Setup

  • node.js v16

Install node v16 on Ubuntu:

sudo apt install npm
sudo npm i -g n
sudo n 16

Get the code

git clone <>

Install dependencies

cd momentswap
npm install

Contract deployment

Set the wallet private key to the .env file:


<aside> ⚠️ Convert the address starting with 0x to FIL address:


Compile the contract:

npx hardhat compile

Deploy the contract to the Filecoin mainnet:

The default network is Hyperspace testnet, add the --network filecoinMainnet parameter

npx hardhat run ./fevm/hardhat/deploy/deployMomentSwapFRC721.ts --network filecoinMainnet

npx hardhat run ./fevm/hardhat/deploy/deployFNSMarket.ts --network filecoinMainnet

npx hardhat run ./fevm/hardhat/deploy/deploySapceFNS.ts --network filecoinMainnet

After each successful deployment, the contract address will be returned. Add the contract address to the .env file:


IPFS storage configuration

The NFT resources in the MomentSwap website are stored on the IPFS network and need to configure the API key

Application address:

Fill the applied API key to the .env file:


Deploy UI using Fleek

Visit and log in:

Authorize github and select the momentswap repository:

<aside> ⚠️ If you are not in the development group of the momentswap repository, you need to fork the code to your own repository to select it


Select the IPFS network and click Next:

Select the main branch:

Select the NextJS framework:

Modify the build command:

Replace with

npm install && npm run compile-contract && npm run build && npm run export

Set the environment variables:

<aside> ⚠️ WALLET_PRIVATE_KEY is a required field, otherwise compilation error will occur, and temporary wallet private keys can be used to complete the deployment


The frontend defaults to the Hyperspace test network. To switch to the Fil main network, you can add the environment variable settings:


Start deployment:

Last updated