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.
| 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) |
User Wallet
│
▼
Next.js Frontend (wagmi + RainbowKit)
│
├── ForgeToken (FORGE) ──stake──▶ StakingRewards ◀──fund── Owner
│ │
└── FogToken (FOG) ◀────claim──────────┘
- Stake: approve and deposit FORGE into
StakingRewards - Earn: pool releases FOG every second, split by stake share
- Claim: pull earned FOG to your wallet
- Unstake: withdraw FORGE from the pool
Uses the standard rewardPerToken pattern. Pending rewards sync on every user action.
| Contract | Role |
|---|---|
ForgeToken |
Staking token (FORGE) |
FogToken |
Reward token (FOG) |
StakingRewards |
Pool: stake, withdraw, claim |
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
- Node.js 18+
- MetaMask (or compatible wallet)
- Sepolia ETH (for testnet deploy)
npm install
npm run compile
npm run test
npm run devcd contracts && npx hardhat nodecd contracts && npx hardhat run scripts/deploy.ts --network localhostCopy the printed addresses into frontend/.env.local.
Deploy mints 1M FORGE to Account #0 only. For another wallet:
cd contracts
FORGE_TOKEN=0xYourForgeAddress MINT_TO=0xYourWallet npm run mint-forgenpm run devOpen http://localhost:3000/stake. Connect MetaMask to Hardhat Local:
| Field | Value |
|---|---|
| RPC | http://127.0.0.1:8545 |
| Chain ID | 31337 |
Restarting
hardhat nodewipes state. Redeploy and update.env.local.
cp contracts/.env.example contracts/.envSEPOLIA_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=50000npm run deploy:sepoliaDeploys contracts, funds the pool, saves addresses to contracts/deployments/sepolia.json, and verifies on Etherscan.
Add the printed addresses to frontend/.env.local, then rebuild or restart the dev server.
| 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) |
| 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 |
| 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 |
See SECURITY.md for trust assumptions and what the contracts protect against.
MIT