Skip to content

Repository files navigation

Staking DeFi Project

A sample DeFi Staking project with Client ans Server side code.

How to run the project


  1. Open the project with your prefered IDE (Like VS Code).
  2. Open a terminal, and go inside the root directory.
  3. Install all dependencies by typing npm install.
  4. create the .env file on the root directory of the project and populate these variables:
    • COINMARKETCAP: Coinmarketcap API to use for live gas price.
    • INFURA_API: Infura API Key to provide a Blockchain node.
    • MAIN_ACCOUNT: The private key of the main accout which will store your RewardToken.
  5. Install Metamask extension in your browser (Chrone is the best choice).
  6. Get fake MATIC token from some faucet website like Option1 or Option2.
  7. Create more accouts and transfer some MATIC Token to them.
  8. Compile hardhat project by typing npx hardhat compile.
  9. Run test case by typing npx hardhat test.
  10. Deploy the Smart Contract on Mumbai Testnet by typing npx hardhat run scripts/Deploy --network mumbai.
  11. Copy both RewardToken and Staking deployment address somewhere.
  12. Replace in the client directory in all components that require these two contract address with the deployed one.
  13. Move to client directory by typing cd client.
  14. Install all dependencies by typing npm install. If yarn is required, install it by typing npm install --global yarn.
  15. Run App in development mode by typing npm run dev.
  16. Connect the DApp with Matamask wallet.
  17. Import Reward Token in the Main Account added before to see RT token balance.
  18. Transfer some Reward Token or RT to others account, and then import on then RewardToken contract address to see token sent.
  19. Send some token to Staking Contract to be used for rewards.
  20. Stake token from differents accounts.
  21. Perform Claim Reward, to get back the earn to user account.
  22. Finally, Withraw RT token to Unstake tokens.

Steps for the project


  1. Writting Smart Contract on Remix IDE.
  2. Testing Smart Contract Behaviour on Remix IDE.
  3. Setup Hardhat project.
  4. Writting test cases.
  5. Setting up Metamask Wallet.
  6. Deploy the Smart Contract on Testnet (Mumbai, Goerli or other testnets).
  7. Run client side.
  8. Test Stake Defi DApp.

UI Screenshots


Dashboard

1-Dashboard

Approve Stake tokens

2-Approve Staking Tx

Confirm Stake tokens

3-Confirm Staking Tx

Claim rewards

4-Claim Rewards

Reward already claimed

5-No more rewards token to claim

Withdraw token

6-Withdraw tokens

Mentor

Thanks to Sanjeevan for his amazing explanations.

About

Staking DeFi Demo Project

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages