How to Create NFT Staking with Reward Features : Minting NFT & NFT Staking Explained – Coinex Smart Chain


After doing the process of deploying token crc20, token nft crc-721 and nft staking, you must continue the steps below, so that the nft staking function can run.

4# Verification Smart Contract

Smart contracts must be verified in the explorer coinex smart chain, so that the smart contract code is public and transparent, after verification anyone can interact with the smart contract through the explorer and browse through the entire code. Users prefer when smart contracts are verified, because nothing is hidden in the smart contract code.

Because the smart contract we use uses several files, we need to combine the files into one (flat), using the flattener plugin in remixIDE.

  • Click the “Plugin Manager” menu, search for “Flattener” and install the plugin
  • Click the smart contract code file that you want to flat, click the “Flattener” icon, click “Flatten” and save the flat

  • After creating a flat file (joined file) you need to enter it into the coinex smart chain explorer
  • Go to explorer, go to smart contract address, Select “Contract Info“, Select “Verify & Publish
  • Fill in all the required details, must be the same as the options you selected in remixIDE (when deploying)

  • Also do (verify) for other smart contracts (crc-721 and nft staking)
5# Approve Address & Smart Contract

Approve address functions so that wallet addresses or staking addresses can transfer/wd/staking tokens (via smart contracts). To approve, you can do it through the explorer coinex smart chain.

  • Go to explorer coinex smart chain, enter address smart contract crc20
  • Select “Contract Info“, Connect your wallet
  • Select “Write Contract“, in the “Approve” section, enter your Wallet & Smart contract address crc721, nft staking in “spender” , and in the “amount” section enter the number of tokens (don’t forget to add the number 0, according to the decimal token)

 

6# Minting NFT

For minting nft we need image files or digital art, metadata, decentralized cloud storage, make sure everything is available.

Upload nft image to IPFS / Sia Network

Images or digital art for nft must be uploaded to decentralized cloud storage, you can use the ipfs service, use the ipfs node itself or use the sia network. In this article we will use a blockchain-based cloud storage service from sia network

  • Create an account at skynetfree.net , and verify your email so that your account is active
  • Upload the nft image file, and get the CID code of the file,
  • Example CID code = PAK1QoxXlFHBlVbaRu6nP3_Scd04ZUuG_NRpMTaNuY84VQ
  • Use Sia Gateway = siasky.net *this gateway is more stable
  • Format url to = https://siasky.net/PAK1QoxXlFHBlVbaRu6nP3_Scd04ZUuG_NRpMTaNuY84VQ

Create Metadata File & Upload

The nft information is stored in the metadata file, there is a need to create those metadata for each nft, and upload it to sia-network or ipfs.

Metadata Format :

{
"name": "Nama NFT",
"image": "https://gateway.ipfs.io/ipfs/QmYmZWH7CrfyQJU9wqxhxLbZ5Aa7d1vwfta3niDABnKdcQ",
"description": "Deskripsi NFT",
"external_url": "https://cryptovir.com/"
}
  • name : Name for the nft
  • image : Image/video/animation/digitalart url for nft
  • description : Description for the nft
  • external_url : Website / social media / forum address from official nft

Create a metadata file with .json extension, and upload the file to sia-network, get the metadata file link (link is used for nft minting process)

 

Minting NFT

Minting nft on coinex smart chain can be through explorer, even though you don’t have a dapps website yet, but you can interact (minting) easily in explorer.

  • Go to explorer coinex smart chain, go to smart contract nft (crc-721)
  • Choose “Contract Info“, “Write Contract
  • Connect your wallet, you can use metamask or wallet connect
  • Select the “Mint” menu, fill in all the required details
  • _to(address) : the address that will receive nft
  • _tokenId(uint256) : unique id for nft
  • _uri(string) : json file url (metadata)
  • Click “Write” for nft minting process

 

7# Staking NFT

Anyone who has NFT can staking into smart contracts, and start earning rewards in the form of crc20 tokens. The amount of reward depends on how much nft you staking and how long you staking

Because this is a smart contract that does not yet have a website, staking is only done in the Coinex Smart Chain explorer.

Smart Contract Staking Information

  • staker : to find out if the wallet (which you check) has staked
  • nftCollection : nft collection (crc-721 token) which can be staked in the smart contract
  • rewardsToken : crc-20 token that you will get after staking (crc20 token reward)

How to Staking

  • Make sure the wallet that will be staking has approved the crc20 smart contract and the crc721 smart contract
  • Enter the smart contract nft staking on coinex smart chain, connect your wallet
  • Select “Write Contract
  • In the stake menu, enter the nft id (crc721 token), click “write” (your token will automatically enter the smart contract and do staking)

How to Claim Reward

  • Enter the smart contract nft staking in explorer coinex smart chain, connect your wallet
  • Go to “Write Contract“, Select “Claim Reward“, Click Write
  • Wait 2-3 seconds, the reward token will enter your wallet

How to Unstake

  • Enter the smart contract nft staking in explorer coinex smart chain, connect your wallet
  • Go to “Write Contract“, Select “Withdraw“, Enter the nft id you want to withdraw, Click Write
  • Wait 2-3 seconds, the crc-721 NFT token will go back into your wallet

 

This smart contract is very useful for developing your project, when there is a stake system in nft, it will encourage more users to buy nft, and users will collect more nft. good luck


Alif Fahmi

hi , I'm Alif, I'm a blockchain & cryptocurrency lover, I love writing & learning, my job is web developer & crypto trader