A demo decentralized token staking platform built with Next.js and Hardhat. Users can stake DIA tokens to earn DAPP token rewards with real-time APR calculations and portfolio tracking.
π Try it live: https://defi.roonnapai.dev/
- Token Staking: Stake DIA tokens to earn DAPP token rewards
- Faucet Integration: Get test DIA tokens for testing
- Real-time Portfolio: Track balances, staking positions, and rewards
- APR Calculations: Dynamic APR based on pool size and rewards
- Proportional Rewards: Fair reward distribution based on stake percentage
- MetaMask Integration: Seamless wallet connection
- Responsive UI: Modern, mobile-friendly interface built with TailwindCSS
- Frontend: Next.js 15, React 19, TypeScript
- Styling: TailwindCSS 4
- Blockchain: Hardhat, Ethers.js 6
- Wallet: MetaMask integration
- Testing: Chai, Hardhat testing framework
- Network: Base Sepolia Testnet
- Node.js 18+ and npm/pnpm
- MetaMask browser extension
- Base Sepolia testnet configured in MetaMask
git clone <your-repo-url>
cd dapp-demo
pnpm install
Create a .env.local
file in the root directory:
# Add your environment variables here
NEXT_PUBLIC_NETWORK_ID=84532
NEXT_PUBLIC_NETWORK_NAME="Base Sepolia"
# Start the development server
pnpm dev
# Or run both blockchain and frontend
pnpm run dev:all
Open http://localhost:3000 to view the application.
- Network Name: Base Sepolia
- RPC URL:
https://sepolia.base.org
- Chain ID: 84532
- Currency Symbol: ETH
- Block Explorer:
https://sepolia.basescan.org
- DIA Token:
0xFe55622104A05e4e0475d2B456A9f6845Ab74d12
- DAPP Token:
0x008Fe3b45778e92804d081d9779d460B2a223DB1
- Token Farm:
0x26cc25E3aE87BE2C49d1EF554dBbA7b8369c6591
- Click "Connect Wallet" button
- Approve MetaMask connection
- Ensure you're on Base Sepolia testnet
- Use the faucet to get DIA tokens for testing
- Faucet provides tokens for staking
- Enter amount to stake
- Approve token spending
- Confirm staking transaction
- Watch your rewards accumulate
- View real-time APR and rewards
- Unstake partially or completely
- Claim earned DAPP token rewards
# Compile contracts
pnpm run compile
# Run tests
pnpm run test
# Start local blockchain
pnpm run node
# Deploy contracts locally
pnpm run deploy
# Run development server
pnpm dev
# Build for production
pnpm build
# Start production server
pnpm start
# Lint code
pnpm lint
dapp-demo/
βββ contracts/ # Smart contracts
β βββ modules/
βββ src/
β βββ app/ # Next.js app router
β βββ components/ # React components
β β βββ ui/ # UI components
β βββ lib/ # Utility libraries
β β βββ blockchain.ts # Blockchain service
β β βββ contracts.ts # Contract definitions
β βββ types/ # TypeScript types
βββ test/ # Contract tests
βββ hardhat.config.ts # Hardhat configuration
βββ next.config.ts # Next.js configuration
βββ tsconfig.json # TypeScript configuration
- Manages Web3 provider and signer
- Handles all contract interactions
- Provides wallet connection functionality
- Calculates staking metrics and APR
- Type-safe contract interfaces
- Contract addresses and ABIs
- Helper functions for token formatting
The project includes comprehensive smart contract tests:
# Run all tests
pnpm test
# Run tests with gas reporting
pnpm test --gas
# Run tests on specific network
pnpm test --network hardhat
Deploy to Vercel with one click:
Update contract addresses in src/lib/contracts.ts
after deployment.
- Type Safety: Full TypeScript implementation
- Security Headers: Configured in Next.js
- Input Validation: Comprehensive error handling
- Web3 Security: Proper transaction handling
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Check the issues page
- Review the documentation
- Join our Discord
- Next.js - React framework
- Hardhat - Ethereum development environment
- Ethers.js - Ethereum library
- TailwindCSS - CSS framework
- Base - L2 blockchain platform
Happy Staking! π