Skip to content

Blockchain Token Staking dApp built with React, Solidity, Truffle on Ethereum testnet, Polygon, Binance Smart Chain, BSC, zkEVM, Coinbase Base Chain, BASE

Notifications You must be signed in to change notification settings

ibnzUK/Token-Staking-dApp

Repository files navigation

Token Staking dApp

Blockchain Token Staking dApp built with React, Solidity, on Ethereum Ganache, Ropsten, Rinkeby testnet networks

Preview

Changes

  • Added ERC20 TestToken
  • Added Token Staking basic contract
  • Started testing
  • Updated Token Staking contract
  • Added ability to stake, unstake, redistribute
  • Implemented testing
  • Added redistribution script
  • Injected web3 and Metamask
  • Ability to detect if Metamask installed, logged, locked
  • Added skeletons for totalStaked, myStake,
  • Added skeletons for Tester to Redistribute rewards and claim test tokens
  • Added ability to load contracts
  • Fetching data from TokenStaking contract
  • Fetching balances
  • Stake, Unstake is now working
  • Redistribute rewards for (Admin only) is now working
  • Implemented totalStaked
  • Implemented ability to claim test token(Tst) (FOR TESTING PURPOSE ONLY)
  • Added amount type validity check
  • Add ability for user to stake max
  • Added ability to listen to triggers .on transactionHash
  • Data automatically fetched after confirmation received
  • Added HDWallet provider and Infura setup
  • Deployed on ropsten and rinkeby
  • Different staking pool implemented customStake/customUnstake
  • Implemented ability for admin to change custom pool APY value via script
  • Implemented custom reward Pool redistribution
  • Contract Source Code Verified (Exact Match)
  • Components split in to smaller
  • Added frontend logic for custom pools
  • Added UI Elements
  • Loaders fixed
  • Added checks and restrictions for when Metamask is not connected
  • UI Optimised for mobiles
  • Production build uploaded to https://ibnz-staking.netlify.app/ for preview and test run
  • Add clear running description
- # Token Staking dApp <h1>

Front end functions to Claim for 1000 Tst token and Redistribute rewards or Custom redistribution are only for testing purpose and showcase of application. Do not include or use them in your final project. Preview

Running instructions

For Testing

  • To run tests from /test/TokenStaking (truffle test)

For Admin Use

  • There are prewritten scripts for Admin use either manually or on daily, weekly basic, ideally with predefined cronjob from the server.
  • All scripts are located in /scripts folder
  • To change APY % run: truffle exec scripts/changeAPY.js 0.137 this script takes 1 argument (daily APY), in this provided example, admin sets 0.137 daily APY Preview
  • To redistribute rewards from the console, run: truffle exec scripts/redistribute.js or provide argument custom if you want to redistribute custom rewards Preview

mocha testing output

   TestToken deployment
     ✓ token deployed and has a name (246ms)
   TokenStaking deployment
     ✓ staking contract deployed and has a name (160ms)
     ✓ checking default APY value (179ms)
     ✓ checking custom APY value (128ms)
     ✓ staking contract has 500k TestTokens tokens inside (176ms)
   TokenStaking stakeTokens function
     ✓ users balance is correct before staking (126ms)
     ✓ checking total staked before any stakes (126ms)
     ✓ approving tokens, staking tokens, checking balance (1259ms)
     ✓ checking contract balance after staking (156ms)
     ✓ checking user balance inside contract (131ms)
     ✓ checking total staked (136ms)
     ✓ testing if user is staking at the moment (148ms)
     ✓ testing if user has staked (145ms)
   TokenStaking redistributeRewards function
     ✓ checking who can do redistribution (1059ms)
     ✓ checking TokenStaking balance (105ms)
     ✓ checking user balance (130ms)
   TokenStaking unstakeTokens function
     ✓ unstaking and checking users balance after unstake (468ms)
     ✓ checking total staked (132ms)
   TokenStaking [custom] staking/unstaking functions
     ✓ checking total custom staked before any stakes (132ms)
     ✓ checking users balance before staking (165ms)
     ✓ approving tokens, staking tokens, checking balance (1131ms)
     ✓ checking custom total staked (125ms)
     ✓ testing if user is staking at custom staking at the moment (147ms)
     ✓ testing if user has staked at custom staking (107ms)
     ✓ unstaking from custom staking and checking users balance  (535ms)
   Claim Tst
     ✓ trying to obtain 1000 test token (395ms)
   Change custom APY value
     ✓ checking who can change APY (1115ms)
     ✓ checking new custom APY value (146ms)
   Testing custom APY reward redistribution
     ✓ staking at customStaking (1299ms)
     ✓ redistributing rewards, checking who can redistribute (733ms)
     ✓ checking user balance after custom APY rewards  (111ms)

For private Ethereum test network make sure Ganache is running on HTTP://127.0.0.1:7545

TokenStaking Smart Contract Address on Test Net

TestToken Contract Address on Test Net

Current Admin on Test Net

  • Ropsten, Rinkeby : 0x3349ca399168dF1c0df96a49410F5F9940241AbC