Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StakeForge

Stake FORGE, earn FOG. Full-stack staking dApp with Solidity, Hardhat, and Next.js.

Connect a wallet, stake tokens, earn rewards, claim or unstake from the dashboard. Works on local Hardhat and Sepolia testnet.

Tech Stack

Layer Stack
Contracts Solidity 0.8.20, Hardhat, OpenZeppelin
Frontend Next.js 14, TypeScript, Tailwind CSS
Web3 wagmi, viem, RainbowKit
Networks Hardhat Local (31337), Sepolia (11155111)

Architecture

User Wallet
    │
    ▼
Next.js Frontend (wagmi + RainbowKit)
    │
    ├── ForgeToken (FORGE) ──stake──▶ StakingRewards ◀──fund── Owner
    │                                      │
    └── FogToken (FOG) ◀────claim──────────┘

How it works

  1. Stake: approve and deposit FORGE into StakingRewards
  2. Earn: pool releases FOG every second, split by stake share
  3. Claim: pull earned FOG to your wallet
  4. Unstake: withdraw FORGE from the pool

Uses the standard rewardPerToken pattern. Pending rewards sync on every user action.

Contracts

Contract Role
ForgeToken Staking token (FORGE)
FogToken Reward token (FOG)
StakingRewards Pool: stake, withdraw, claim

Project Structure

StakeForge/
├── contracts/
│   ├── contracts/       # Solidity source
│   ├── scripts/         # Deploy + mint scripts
│   ├── test/            # Hardhat tests
│   └── deployments/     # Saved deploy output (gitignored)
├── frontend/
│   ├── app/             # Pages (/, /stake)
│   ├── components/      # UI + wallet
│   ├── hooks/           # useStakingPool
│   └── lib/             # ABIs, wagmi config, helpers
└── package.json         # npm workspaces

Prerequisites

  • Node.js 18+
  • MetaMask (or compatible wallet)
  • Sepolia ETH (for testnet deploy)

Quick Start

npm install
npm run compile
npm run test
npm run dev

Local Development

1. Start Hardhat node

cd contracts && npx hardhat node

2. Deploy contracts

cd contracts && npx hardhat run scripts/deploy.ts --network localhost

Copy the printed addresses into frontend/.env.local.

3. Mint FORGE to your wallet

Deploy mints 1M FORGE to Account #0 only. For another wallet:

cd contracts
FORGE_TOKEN=0xYourForgeAddress MINT_TO=0xYourWallet npm run mint-forge

4. Run the frontend

npm run dev

Open http://localhost:3000/stake. Connect MetaMask to Hardhat Local:

Field Value
RPC http://127.0.0.1:8545
Chain ID 31337

Restarting hardhat node wipes state. Redeploy and update .env.local.

Sepolia Deployment

1. Configure contracts/.env

cp contracts/.env.example contracts/.env
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
PRIVATE_KEY=your_wallet_private_key_without_0x
ETHERSCAN_API_KEY=your_etherscan_api_key
REWARD_RATE=0.001
POOL_FUNDING=50000

2. Deploy and verify

npm run deploy:sepolia

Deploys contracts, funds the pool, saves addresses to contracts/deployments/sepolia.json, and verifies on Etherscan.

3. Update frontend

Add the printed addresses to frontend/.env.local, then rebuild or restart the dev server.

Environment Variables

contracts/.env

Variable Description
SEPOLIA_RPC_URL Sepolia RPC endpoint
PRIVATE_KEY Deployer private key
ETHERSCAN_API_KEY For contract verification
REWARD_RATE FOG per second (default 0.001 on Sepolia)
POOL_FUNDING FOG sent to pool at deploy (default 50000)

frontend/.env.local

Variable Description
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID WalletConnect Cloud project ID
NEXT_PUBLIC_STAKING_TOKEN_ADDRESS ForgeToken address
NEXT_PUBLIC_REWARDS_TOKEN_ADDRESS FogToken address
NEXT_PUBLIC_STAKING_CONTRACT_ADDRESS StakingRewards address

Scripts

Command Description
npm run compile Compile contracts
npm run test Run Hardhat tests (24 tests)
npm run dev Start Next.js dev server
npm run build Production build
npm run deploy:local Deploy to Hardhat node
npm run deploy:sepolia Deploy + verify on Sepolia

Security

See SECURITY.md for trust assumptions and what the contracts protect against.

License

MIT

About

Stake FORGE, earn FOG. Full- tack Ethereum staking dApp with Solidity, Hardhat, and Next.js.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages