Fortune Lottery DApp
Fortune Lottery is a decentralized Web3 lottery DApp deployed on the Avalanche Fuji Testnet. It features automated smart contract draws, ERC-20 (TRDO) ticket purchasing, on-chain 10-level referral commission distribution, and background execution bots.

Traditional online lotteries lack transparency, suffer from opaque winner draw selection, and fail to provide verifiable proof of ticket sales or prize payouts.
Engineered audit-ready Solidity smart contracts executing on Avalanche EVM testnet, backed by automated Node.js background bots that scan on-chain events, purchase unsold tickets, distribute commissions, and declare verifiable winners.
Key Engineered Features
Decentralized Ticket Purchasing
Web3 wallet connection (MetaMask, WalletConnect) executing ERC-20 token approval and ticket purchases.
10-Level On-Chain Referral Matrix
Direct multi-level referral commissions automatically calculated and assigned on-chain.
Automated Draw Lifecycle Bots
3 dedicated owner wallets executing ticket purchases for unsold allocations, commission payouts, and winner selection.
Real-Time Etherscan/Snowtrace Indexer
Node.js background scanner polling blockchain events into MongoDB for instant UI reporting.
Transparency & Payout Verification
Verifiable on-chain winner declaration, win reports, and ticket purchase audits.
Platform Dashboard Visuals

Technical Architecture Breakdown
Next.js 15 App Router with Wagmi v2 & Reown AppKit for reactive wallet state management.
MongoDB Atlas for caching draw events, user registration trees, and transaction logs.
Development Lifecycle & Steps
Smart Contract Engineering
Wrote Solidity contracts with 10-level referral arrays and pseudo-random winner selection.
Web3 Frontend Integration
Built Next.js 15 UI with Reown Web3Modal and Wagmi v2 hooks for seamless wallet connection.
Automated Worker Bots
Configured 3 owner wallets (Ticket Buyer, Commission Bot, Winner Bot) managed by Node-Schedule.
Event Indexing Engine
Developed background indexer scanning block logs and storing real-time draw stats in MongoDB.
Testnet Deployment & Verification
Deployed contracts on Avalanche Fuji testnet and verified transactions via Snowtrace.
Technical Obstacles & Solutions
Challenge: Ensuring automated winner pick functions execute reliably when a draw expires without manual intervention.
Solution: Built a multi-worker bot architecture with 3 isolated private key signers handling ticket closure, commission payouts, and winner resolution sequentially.
Challenge: Slow direct RPC calls delaying ticket history loading on frontend client components.
Solution: Created a background event scanner syncing on-chain events into MongoDB, delivering sub-20ms database queries for UI reports.