Back to All Projects
Web3 / Decentralized Smart Contract DApp

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.

Next.js 15SolidityWagmi v2Reown AppKit (Web3Modal)ViemRedux ToolkitNode.jsExpressMongoDBAvalanche Fuji
Year Completed2026
Engineering RoleLead Web3 & Smart Contract Engineer
Project TypeWeb3 DApp / Smart Contract System
Fortune Lottery DApp
The Production Challenge

Traditional online lotteries lack transparency, suffer from opaque winner draw selection, and fail to provide verifiable proof of ticket sales or prize payouts.

The Engineering Solution

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

Fortune Lottery DApp Preview 1
👤 User Operational Workspace

Technical Architecture Breakdown

SYSTEM ARCHITECTURE BLUEPRINT
PRODUCTION VERIFIED
1. Client & Gateway

Next.js 15 App Router with Wagmi v2 & Reown AppKit for reactive wallet state management.

Gateway:
2. Business & Service Layer

3. Database & AWS Cloud

MongoDB Atlas for caching draw events, user registration trees, and transaction logs.

Cloud: AWS EC2 host running 3 automated cronjob bots for draw execution and referral payouts.

Development Lifecycle & Steps

01

Smart Contract Engineering

Wrote Solidity contracts with 10-level referral arrays and pseudo-random winner selection.

02

Web3 Frontend Integration

Built Next.js 15 UI with Reown Web3Modal and Wagmi v2 hooks for seamless wallet connection.

03

Automated Worker Bots

Configured 3 owner wallets (Ticket Buyer, Commission Bot, Winner Bot) managed by Node-Schedule.

04

Event Indexing Engine

Developed background indexer scanning block logs and storing real-time draw stats in MongoDB.

05

Testnet Deployment & Verification

Deployed contracts on Avalanche Fuji testnet and verified transactions via Snowtrace.

Technical Obstacles & Solutions

ENGINEERING OBSTACLE 01

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.

ENGINEERING OBSTACLE 02

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.

Verified Production Metrics

✓ Benchmarked on AWS Infrastructure
100%
On-Chain Transparency & Verifiability
< 20ms
Cached Event Query Speed
10-Tiers
Automated Referral Matrix Payouts
Up Next

Elevated MarketingSaaS / Multi-Leg Affiliate & E-Commerce

Next Case Study