A simple decentralized ETH staking dApp built with Solidity, JavaScript, HTML, CSS, and Ethers.js.
Users can connect their MetaMask wallet, stake ETH into a smart-contract pool, earn rewards based on the configured APY, and withdraw their stake and rewards.
- Connect MetaMask wallet
- Automatically switch to Sepolia Testnet
- Stake ETH
- View staked amount
- Calculate earned rewards
- Check current APY
- View total stakes in the pool
- View contract pool balance
- Unstake ETH
- Withdraw stake and rewards
Connect Wallet
↓
Sepolia Testnet
↓
Stake ETH
↓
Smart Contract Pool
↓
Rewards accumulate over time
↓
Calculate Reward
↓
Unstake
↓
Receive ETH + Rewards
The frontend interacts with the deployed staking contract through Ethers.js. The contract tracks each user's stake and starting time and calculates rewards based on the configured APY.
- Solidity
- JavaScript
- HTML
- CSS
- Ethers.js
- MetaMask
- Sepolia Testnet
stake()
unstake()
myStake()
calculateMyReward()
APY()
totalStakes()
balance(address)
startTime(address)
getBalance()
allWithdraw()The frontend uses these functions to perform staking transactions and read on-chain data.
git clone https://github.com/mohit-solidity/StakingDapp.git
cd StakingDappThis is a vanilla HTML/JavaScript project, so it does not require a React or Node.js build setup.
Open:
index.html
in a browser with MetaMask installed.
The dApp is configured to use:
Sepolia Testnet
Chain ID: 11155111
You will need Sepolia ETH to interact with the contract. The frontend explicitly switches the wallet to Sepolia when connecting.
StakingDapp/
├── index.html
├── style.css
├── script.js
└── README.md
This project is for educational purposes and has not been professionally audited. Do not use it with real funds.
Mohit Sharma
Blockchain Developer | Solidity • React.js • Ethers.js