Skip to content

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

LayerStack
ContractsSolidity 0.8.20, Hardhat, OpenZeppelin
FrontendNext.js 14, TypeScript, Tailwind CSS
Web3wagmi, viem, RainbowKit
NetworksHardhat 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

ContractRole
ForgeTokenStaking token (FORGE)
FogTokenReward token (FOG)
StakingRewardsPool: 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:

FieldValue
RPChttp://127.0.0.1:8545
Chain ID31337

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_KEYPRIVATE_KEY=your_wallet_private_key_without_0xETHERSCAN_API_KEY=your_etherscan_api_keyREWARD_RATE=0.001POOL_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

VariableDescription
SEPOLIA_RPC_URLSepolia RPC endpoint
PRIVATE_KEYDeployer private key
ETHERSCAN_API_KEYFor contract verification
REWARD_RATEFOG per second (default 0.001 on Sepolia)
POOL_FUNDINGFOG sent to pool at deploy (default 50000)

frontend/.env.local

VariableDescription
NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDWalletConnect Cloud project ID
NEXT_PUBLIC_STAKING_TOKEN_ADDRESSForgeToken address
NEXT_PUBLIC_REWARDS_TOKEN_ADDRESSFogToken address
NEXT_PUBLIC_STAKING_CONTRACT_ADDRESSStakingRewards address

Scripts

CommandDescription
npm run compileCompile contracts
npm run testRun Hardhat tests (24 tests)
npm run devStart Next.js dev server
npm run buildProduction build
npm run deploy:localDeploy to Hardhat node
npm run deploy:sepoliaDeploy + 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