Skip to content

basantsd/staking-reward

Repository files navigation

🏦 Staking & Reward DApp

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.

🚀 What does it do?

  • Stake Tokens: Users can deposit their StakeToken into the smart contract.
  • Earn Rewards: Staked tokens yield RewardToken at 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.

🛠️ Tech Stack

  • 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

💻 Getting Started

Want to run this locally? It's super easy. Just follow these steps:

1. Install dependencies

Make sure you're in the project directory, then run:

pnpm install

2. Set up your environment variables

Copy the example environment file:

cp .env.example .env

Open the newly created .env file and add your Hardhat local network private key. (Don't worry, .env is ignored by Git automatically!).

3. Start a local blockchain node

In a separate terminal window, get your local network going:

npx hardhat node

4. Deploy the smart contracts

With the Hardhat node running perfectly, open a new terminal tab and deploy the contracts:

node scripts/deploy.js

Tip: This deployment script is actually pretty smart! It automatically copies the deployed contract addresses directly to the frontend.

5. Start the frontend

Finally, fire up the development server:

pnpm run dev

Open up http://localhost:5173 in your browser and start playing around with the staking mechanics!

🔐 Security Note

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.

📜 Contribution & License

Feel free to fork, tweak, and use this code for your own learning! Happy Web3 coding! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors