A Next.js frontend for the satirical email-writing experience by the SADCOIN Foundation, featuring real-time blockchain integration with Ethereum smart contracts on Sepolia testnet.
"Let's Write An Email" is a semi-fictional, totally-satirical experience by the SADCOIN Foundation where players:
- Purchase SADCoin tokens with ETH at $0.01 each (using Chainlink price feeds)
- Earn FEELS tokens through emotional interactions
- Convert FEELS to additional SADCoin tokens
- Track sadness levels and emotional damage on-chain
- Node.js 18+ and npm
- MetaMask or compatible Web3 wallet
- Sepolia testnet ETH for transactions
# Clone and install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Add your WalletConnect Project ID to .env.local
# Start development server
npm run devCreate .env.local with:
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id_here
Get a free Project ID from WalletConnect Cloud.
- SADCoin Token:
0xace84066b7e68f636dac3c3438975de22cf4af20 - FEELS Token:
0xe5180fa5acaf05717d49bf2ec4f6fd0261db92b2 - StakingContract:
0xf62ab5625521f4a9883565b72ddc4f86098f1062 - GameRewards:
0x47bea96317ddcc926696f83db55389898493dbcd - ConversionContract:
0x2dbfae1ff52735a145bbdfc0822085143bd462e3 - NFTClaim:
0x037feb654b637226b5503a237361d1c3b4de7b30
- Auto-Network Switching: Automatically switches to Sepolia on wallet connection
- Real-time Price Feeds: Uses Chainlink ETH/USD oracle for accurate pricing
- Live Balance Updates: Real-time token balance monitoring via event watching
- Purchase Cooldowns: 24-hour cooldown between SADCoin purchases
- Debug Interface: Comprehensive testing tools for developers
- Next.js 14: React framework with App Router
- Wagmi v2: React hooks for Ethereum interactions
- Viem: TypeScript Ethereum library
- TailwindCSS: Utility-first styling
- TypeScript: Type-safe development
- Contract addresses and ABIs
- Network configuration (Sepolia-only)
- Type-safe contract constants
useSADCoinBalance()- Real-time SAD token balanceuseFEELSBalance()- Real-time FEELS token balanceusePurchaseCalculation()- ETH to SAD conversion previewusePurchaseSadness()- Execute SAD token purchasesuseConvertFeelsToSad()- Convert FEELS to SAD tokens- Event watchers for real-time updates
- DebugModal: Developer testing interface
- PriceCalculator: Real-time price calculations
- NetworkSwitcher: Automatic Sepolia switching
- DebugPanel: Comprehensive blockchain debugging
- Connect wallet (auto-switches to Sepolia)
- Enter ETH amount or desired SAD tokens
- Preview conversion using real-time ETH/USD price
- Execute purchase (24-hour cooldown applies)
- Receive SAD tokens and FEELS tokens
- Earn FEELS through game interactions
- Convert FEELS to additional SAD tokens
- Dynamic conversion rate based on contract logic
- Sadness Level: Increases with purchases
- Emotional Damage: Accumulates over time
- Purchase History: On-chain transaction tracking
Access via "๐ง DEBUG" button in navigation:
-
Price Calculator
- Real-time ETH/USD pricing
- Purchase amount calculations
- Conversion rate display
-
Simple Test
- Basic contract interaction testing
- Balance verification
- Network status checks
-
Debug Panel
- Complete blockchain state monitoring
- Transaction testing with MetaMask
- Event watching and status tracking
- Purchase and conversion testing
- Connect MetaMask to Sepolia testnet
- Ensure sufficient Sepolia ETH balance
- Open debug modal for testing tools
- Test purchases with small ETH amounts (0.001+ ETH)
- Monitor real-time balance updates
- Verify cooldown mechanics
src/
โโโ components/
โ โโโ ui/ # Shadcn/ui components
โ โโโ DebugModal.tsx # Developer testing interface
โ โโโ DebugPanel.tsx # Blockchain debugging tools
โ โโโ PriceCalculator.tsx # Real-time price calculations
โ โโโ SimpleTest.tsx # Basic contract testing
โ โโโ NetworkSwitcher.tsx # Network management
โ โโโ NavBar.tsx # Navigation with wallet connection
โ โโโ WagmiProviders.tsx # Blockchain provider setup
โโโ hooks/
โ โโโ useContracts.ts # Contract interaction hooks
โโโ lib/
โ โโโ contracts.ts # Contract constants and ABIs
โโโ email-game.tsx # Main game interface
MetaMask not triggering for purchases:
- Ensure sufficient ETH balance (minimum 0.001 ETH recommended)
- Check Sepolia network connection
- Verify contract addresses are correct
- Use debug panel to test with larger ETH amounts
Network switching issues:
- Manually add Sepolia to MetaMask if auto-switch fails
- Check WalletConnect Project ID configuration
- Ensure wallet supports programmatic network switching
Balance not updating:
- Wait for transaction confirmation (1-2 blocks)
- Check transaction status on Sepolia Etherscan
- Use debug panel refresh functionality
- Open browser console for detailed error logs
- Use debug modal for step-by-step testing
- Verify wallet connection and network
- Check contract interaction logs
- Monitor transaction status on Etherscan
- Mainnet deployment preparation
- Enhanced emotional interaction mechanics
- Leaderboard and social features
- Mobile wallet optimization
- Advanced analytics dashboard
- Multi-chain support
MIT License - see LICENSE file for details.
- Fork the repository
- Create 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 Pull Request
Built with ๐ for the blockchain gaming community