A complete Web3 frontend application built with Next.js, Wagmi, Viem, and RainbowKit for interacting with smart contracts.
- View token balance
- Transfer tokens
- Approve spending allowances
- EIP-2612 permit signatures support
- Traditional Deposit: Approve + Deposit (two transactions)
- ⚡ Permit Deposit (EIP-2612): Sign + Deposit in one transaction (gasless approval)
- Withdraw tokens anytime
- Track savings balance
- Real-time balance updates
- Mint unique NFTs (owner only)
- View NFT collection
- Check token metadata URIs
- Track total supply
- List NFTs for sale
- Traditional Buy: Standard NFT purchase with token payment
- 🎫 Whitelist Buy (EIP-712): Purchase with market owner signature (presales/VIP access)
- Owner Tools: Generate whitelist signatures for exclusive sales
- Secure P2P trading
- Next.js 14 - React framework with App Router
- Wagmi - React hooks for Ethereum
- Viem - TypeScript interface for Ethereum
- RainbowKit - Beautiful wallet connection UI
- TailwindCSS - Utility-first CSS framework
- TypeScript - Type-safe development
- Node.js 18+ and npm/yarn
- MetaMask or compatible Web3 wallet
- Smart contracts deployed (see
/contracts)
# Install dependencies
npm install
# Or with yarn
yarn installEdit utils/contracts.ts and update the contract addresses after deployment:
export const CONTRACT_ADDRESSES = {
MyERC20: '0x...', // Your deployed MyERC20 address
TokenBank: '0x...', // Your deployed TokenBank address
MyNFT: '0x...', // Your deployed MyNFT address
NFTMarket: '0x...', // Your deployed NFTMarket address
};Edit utils/wagmiConfig.ts and utils/viemClient.ts to configure your network:
- For local development:
http://127.0.0.1:8545(Hardhat/Anvil) - For testnet: Use Sepolia or other testnet RPC
- For mainnet: Use production RPC URL
Get a free Project ID from WalletConnect Cloud and update it in utils/wagmiConfig.ts:
projectId: 'YOUR_PROJECT_ID',# Development mode
npm run dev
# Build for production
npm run build
# Start production server
npm startThe application will be available at http://localhost:3000
frontend/
├── app/ # Next.js App Router pages
│ ├── page.tsx # Home page
│ ├── token/page.tsx # Token management
│ ├── bank/page.tsx # Token bank
│ ├── nft/page.tsx # NFT collection
│ ├── market/page.tsx # NFT marketplace
│ └── layout.tsx # Root layout with navigation
├── components/ # Reusable React components
│ ├── WalletConnectButton.tsx
│ └── TokenBalance.tsx
├── utils/ # Utility functions and configs
│ ├── contracts.ts # Contract addresses and ABIs
│ ├── viemClient.ts # Viem client configuration
│ └── wagmiConfig.ts # Wagmi configuration
├── styles/
│ └── globals.css # Global styles and Tailwind
├── package.json
├── next.config.js
├── tailwind.config.js
└── tsconfig.json
- Click "Connect Wallet" button in the navigation bar
- Select your preferred wallet (MetaMask, WalletConnect, etc.)
- Approve the connection
- Navigate to Token page
- View your MERC20 balance
- Transfer tokens by entering recipient address and amount
- Approve spending for contracts
- Navigate to Bank page
- Deposit: Approve tokens first, then deposit
- Withdraw: Enter amount and withdraw to your wallet
- View wallet and bank balances
- Navigate to NFT page
- Mint (owner only): Enter recipient and token URI
- View: Enter token ID to see metadata
- Navigate to Market page
- List NFT: Approve NFT first, then set price
- Buy NFT: View listing, approve tokens, then buy
- Whitelist Buy: Requires signature from market owner
Most operations require two steps:
- Approve: Grant permission to the contract
- Execute: Perform the actual operation
- All transactions require gas fees in ETH
- Ensure you have enough ETH for gas
Make sure you're connected to the correct network (Hardhat/Sepolia/etc.)
The app uses:
- Wagmi hooks for reading contract state
- Viem for type-safe contract interactions
- RainbowKit for wallet management
- Create new page in
app/directory - Add route to navigation in
app/layout.tsx - Use Wagmi hooks for contract interactions
- Add contract ABI to
utils/contracts.tsif needed
The project uses TailwindCSS with custom utilities in globals.css:
- Responsive design built-in
- Custom animations and transitions
- Glass morphism effects
- Gradient text utilities
- Clear browser cache and reconnect
- Try different wallet or browser
- Check network configuration
- Ensure sufficient balance
- Check token/NFT approvals
- Verify contract addresses
- Review gas settings
- Verify contract is deployed
- Check contract addresses in
contracts.ts - Ensure correct network selected
- Never share private keys
- Always verify transaction details before signing
- Use testnet for development
- Audit smart contracts before mainnet deployment
MIT
For issues and questions:
- Check contract deployment status
- Verify configuration in
utils/files - Review browser console for errors
- Test with smaller amounts first