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 testnet

Preview

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 TESTIN 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
  • Add clear running description

Running instructions

For Testing

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

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)
     ✓ aproving 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 usrs balance before staking (165ms)
     ✓ aproving 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