Hey there! 👋 Welcome to the Staking & Reward DApp.
This project is a decentralized application (DApp) that allows users to stake their tokens and earn rewards over time. I built this as part of my blockchain learning journey, focusing on writing secure smart contracts and connecting them to a modern React frontend.
- Stake Tokens: Users can deposit their
StakeTokeninto the smart contract. - Earn Rewards: Staked tokens yield
RewardTokenat a predefined APY (currently set to roughly ~14.2%!). - Withdraw & Claim: Users can withdraw their staked tokens and intuitively claim their accrued rewards whenever they want.
- Frontend: React + Vite + Tailwind CSS (for a fast and beautiful UI)
- Smart Contracts: Solidity (compiled and tested with Hardhat)
- Web3 Integration: Ethers.js v6
- Security Standards: OpenZeppelin Contracts v5
Want to run this locally? It's super easy. Just follow these steps:
Make sure you're in the project directory, then run:
pnpm installCopy the example environment file:
cp .env.example .envOpen the newly created .env file and add your Hardhat local network private key. (Don't worry, .env is ignored by Git automatically!).
In a separate terminal window, get your local network going:
npx hardhat nodeWith the Hardhat node running perfectly, open a new terminal tab and deploy the contracts:
node scripts/deploy.jsTip: This deployment script is actually pretty smart! It automatically copies the deployed contract addresses directly to the frontend.
Finally, fire up the development server:
pnpm run devOpen up http://localhost:5173 in your browser and start playing around with the staking mechanics!
Please never commit your .env file or share your private keys anywhere public. This repository is already set up to ignore .env files so you're protected out of the box.
Feel free to fork, tweak, and use this code for your own learning! Happy Web3 coding! 🚀