Skip to content

MehdiKhosa50/PeoplesStakingDapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐’๐ญ๐š๐ค๐ข๐ง๐  ๐’๐ฆ๐š๐ซ๐ญ ๐‚๐จ๐ง๐ญ๐ซ๐š๐œ๐ญ ๐๐ซ๐จ๐ฃ๐ž๐œ๐ญ

#Overview This project implements a staking smart contract system using Solidity and Hardhat. Users can stake ERC20 tokens and earn rewards over time. The system includes a main Staking contract, along with separate ERC20 tokens for staking and rewards.

๐…๐ž๐š๐ญ๐ฎ๐ซ๐ž๐ฌ Stake ERC20 tokens Earn rewards based on staking duration and amount Withdraw staked tokens Claim accumulated rewards Configurable reward rate

๐“๐ž๐œ๐ก๐ง๐จ๐ฅ๐จ๐ ๐ข๐ž๐ฌ ๐”๐ฌ๐ž๐ Solidity ^0.8.0 Hardhat Ethers.js OpenZeppelin Contracts Chai (for testing)

๐๐ซ๐จ๐ฃ๐ž๐œ๐ญ ๐’๐ญ๐ซ๐ฎ๐œ๐ญ๐ฎ๐ซ๐ž โ”œโ”€โ”€ contracts/ โ”‚ โ”œโ”€โ”€ Staking.sol โ”‚ โ”œโ”€โ”€ RewardToken.sol โ”‚ โ””โ”€โ”€ StakedToken.sol โ”œโ”€โ”€ test/ โ”‚ โ””โ”€โ”€ Staking.js โ”œโ”€โ”€ scripts/ โ”œโ”€โ”€ hardhat.config.js โ””โ”€โ”€ package.json Setup

๐‚๐ฅ๐จ๐ง๐ž ๐ญ๐ก๐ž ๐ซ๐ž๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ: git clone cd

๐ˆ๐ง๐ฌ๐ญ๐š๐ฅ๐ฅ ๐๐ž๐ฉ๐ž๐ง๐๐ž๐ง๐œ๐ข๐ž๐ฌ: npm install

๐‚๐จ๐ฆ๐ฉ๐ข๐ฅ๐ž ๐ญ๐ก๐ž ๐œ๐จ๐ง๐ญ๐ซ๐š๐œ๐ญ๐ฌ: npx hardhat compile

๐‘๐ฎ๐ง ๐ญ๐ž๐ฌ๐ญ๐ฌ: npx hardhat test

๐‘๐ฎ๐ง๐ง๐ข๐ง๐  ๐“๐ž๐ฌ๐ญ๐ฌ: The project includes a comprehensive test suite. To run the tests: npx hardhat test This will run all tests in the test/ directory. Deployment ๐“๐จ ๐๐ž๐ฉ๐ฅ๐จ๐ฒ ๐ญ๐ก๐ž ๐œ๐จ๐ง๐ญ๐ซ๐š๐œ๐ญ๐ฌ ๐ญ๐จ ๐š ๐ง๐ž๐ญ๐ฐ๐จ๐ซ๐ค:

Set up your network configuration in hardhat.config.js Create a deployment script in the scripts/ directory ๐‘๐ฎ๐ง ๐ญ๐ก๐ž ๐๐ž๐ฉ๐ฅ๐จ๐ฒ๐ฆ๐ž๐ง๐ญ ๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ: npx hardhat run scripts/deploy.js --network

๐‚๐จ๐ง๐ญ๐ซ๐š๐œ๐ญ ๐ƒ๐ž๐ญ๐š๐ข๐ฅ๐ฌ Staking.sol The main contract that handles staking, withdrawing, and reward distribution.

๐Š๐ž๐ฒ ๐Ÿ๐ฎ๐ง๐œ๐ญ๐ข๐จ๐ง๐ฌ: Stake(uint256 _amount): Stake tokens Withdraw(uint256 _amount): Withdraw staked tokens ClaimReward(): Claim accumulated rewards

RewardToken.sol and StakedToken.sol ERC20 token contracts for the reward and staked tokens respectively. Security Considerations

The contract uses OpenZeppelin's SafeMath library to prevent overflow/underflow issues. Token transfers are checked for success to prevent silent failures. The contract includes access control to prevent unauthorized actions.

๐‡๐จ๐ฐ๐ž๐ฏ๐ž๐ซ, ๐›๐ž๐Ÿ๐จ๐ซ๐ž ๐๐ž๐ฉ๐ฅ๐จ๐ฒ๐ข๐ง๐  ๐ญ๐จ ๐š ๐ฅ๐ข๐ฏ๐ž ๐ง๐ž๐ญ๐ฐ๐จ๐ซ๐ค:

Conduct a thorough code review. Consider getting a professional audit, especially if significant value will be managed by the contract. Test extensively on a testnet before deploying to mainnet.

Contributing Contributions are welcome! Please feel free to submit a Pull Request. ๐‹๐ข๐œ๐ž๐ง๐ฌ๐ž ๐“๐ก๐ข๐ฌ ๐ฉ๐ซ๐จ๐ฃ๐ž๐œ๐ญ ๐ข๐ฌ ๐ฅ๐ข๐œ๐ž๐ง๐ฌ๐ž๐ ๐ฎ๐ง๐๐ž๐ซ ๐ญ๐ก๐ž ๐Œ๐ˆ๐“ ๐‹๐ข๐œ๐ž๐ง๐ฌ๐ž.

About

A Solidity-based staking system that allows users to stake ERC20 tokens and earn rewards over time. Built with Hardhat and OpenZeppelin, this project implements secure staking, withdrawal, and reward claiming functionalities, complete with comprehensive testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors