NFT Yield Farming on BSC
【Introduction of the NFT Yield Farming on BSC】
- This is a smart contract that enable a user to farm yield by staking LP tokens (BEP20) into a NFT pool.
- Once a user stake LP tokens into a NFT pool, reward token (Governance Token) are mined every block.
- User who staked can receive the Governance Tokens as rewards (as farmed-yield) when that user un-stake.
- This smart contract works on BSC (Binance Smart Chain).
【Workflow】
【Setup】
① Install modules
- Install npm modules in the root directory
$ npm install
② Add .env
to the root directory.
- Please copy code of
.env.example
into your.env
(Then, please input your information of wallets, private keys, etc... by following code of.env.example
) https://github.com/masaun/NFT-yield-farming/blob/main/.env.example
③ Compile contracts (on BSC testnet)
$ npm run compile:bsc-testnet
④ Test
- Execute test of the smart-contracts (on the BSC testnet)
- [Note]: Sometime, timeout happen on this test. So I recommend that you try
⑤ Script
below instead of this test.
- [Note]: Sometime, timeout happen on this test. So I recommend that you try
$ npm run test:nft-yield-farming_bsc-testnet
($ truffle test ./test/test-bsc/NFTYieldFarmingOnBSC.test.js --network bsc_testnet)
⑤ Script
- Execute script of the smart-contracts on the BSC testnet (with
truffle exec
command)
$ npm run script:nft-yield-farming_bsc-testnet
($ truffle exec ./scripts/script-bsc/NFTYieldFarmingOnBSC.script.js --network bsc_testnet)
(※ Note: In advance, please check whether your deployer' wallet address on BSC testnet has enough BNB balance or not)
【Remarks】
- When 503 Error happen, please select a new
BSC RPC Endpoints
to change by referencing the list below https://docs.binance.org/smart-chain/developer/rpc.html ↓ - Then, please replace
BSC RPC Endpoints
for 2 files below.- truffle-config.js https://github.com/masaun/NFT-yield-farming/blob/main/truffle-config.js#L9
- NFTYieldFarmingOnBSC.script.js https://github.com/masaun/NFT-yield-farming/blob/main/scripts/script-bsc/NFTYieldFarmingOnBSC.script.js#L5
- Governance Token
- At the moment, Governance Token is used as a reward token.
- Although it has not implemented yet, I will implement Governance Token for governance strucure (e.g. Governance Token holders can vote, etc...) in the future.
- LP tokens
- LP token is created by BEP20.
- Assuming LP tokens is a pair between the Governance Token and BNB.
- But, pool to create this pair (LP tokens) has not been implemented yet. (at the mement)
- Version
- Solidity (Solc): v0.6.12
- Truffle: v5.1.60
- web3.js: v1.2.9
- openzeppelin-solidity: v3.2.0
【References】
- BSC
- Getting Started with BSC: https://binancex.dev/blog.html?p=making-the-move-from-ethereum-to-bsc
- BSC blockchain explorer https://explorer.binance.org/smart-testnet
- BSC testnet faucet https://testnet.binance.org/faucet-smart
- BSC smart contract IDE http://remix.ethereum.org/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.7.4+commit.3f05b770.js
- BSC development ecosystem and tools https://github.com/binance-chain/bsc-develop-ecosystem/
- BSC FAQ https://docs.google.com/document/d/1JF_P-AokXhSe38bNqLTNhlhKIu0JrcNRVReGdoBA-0o/edit?usp=sharing
- BSC
- BSC RPC Endpoints:
https://docs.binance.org/smart-chain/developer/rpc.html