Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Staking DApp

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.

Features

  • 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

How It Works

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.

Tech Stack

  • Solidity
  • JavaScript
  • HTML
  • CSS
  • Ethers.js
  • MetaMask
  • Sepolia Testnet

Main Contract Functions

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.

Getting Started

Clone

git clone https://github.com/mohit-solidity/StakingDapp.git
cd StakingDapp

Run

This 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.

Network

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.

Project Structure

StakingDapp/
├── index.html
├── style.css
├── script.js
└── README.md

Security Note

This project is for educational purposes and has not been professionally audited. Do not use it with real funds.

Author

Mohit Sharma

Blockchain Developer | Solidity • React.js • Ethers.js

GitHub: https://github.com/mohit-solidity

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages