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 <https://github.com/momentswap/momentswap.git>
Install dependencies
cd momentswap
npm install
Contract deployment
Set the wallet private key to the .env
file:
WALLET_PRIVATE_KEY=<YOUR_PRIVATE_KEY>
<aside> ⚠️ Convert the address starting with 0x to FIL address:https://explorer.glif.io/
</aside>
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:
NEXT_PUBLIC_MOMENTSWAP_CONTRACT_ADDRESS=<CONTRACT_ADDRESS>
NEXT_PUBLIC_FNS_MARKET_CONTRACT_ADDRESS=<CONTRACT_ADDRESS>
NEXT_PUBLIC_SPACE_FNS_CONTRSCT_ADDRESS=<CONTRACT_ADDRESS>
IPFS storage configuration
The NFT resources in the MomentSwap website are stored on the IPFS network and need to configure the nft.storage API key
Application address:https://nft.storage/
Fill the applied API key to the .env
file:
NEXT_PUBLIC_NFT_STORAGE_API_KEY=<API_KEY>
Deploy UI using Fleek
Visit and log in:https://app.fleek.co/

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
</aside>

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
</aside>


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

Start deployment:

Last updated