Provably Fair Coin Flip Betting on Base
Challenge anyone to a coin flip duel. Bet USDC, earn rewards, build streaks. All powered by Chainlink VRF on Base network.
Current Version: v0.1.0 (Testnet Ready) Phase: 15/17 Complete (87%) Build Status: โ Passing Test Coverage: 70/70 tests passing
Ready for: Base Sepolia deployment Next: Testnet testing โ Mainnet deployment
- ๐ฒ Coin Flip Betting - Challenge any address, 1+ USDC bets, provably fair
- ๐ฅ Daily Streaks - Check in daily, earn up to 150 USDC at milestones
- ๐ฅ Referral System - 1 USDC signup bonus + 5% of all referral bets
- ๐ Daily Free Flip - Free flip every 24 hours, funded by platform fees
- ๐ Statistics - Track games, wins, profit, win rate
- ๐ Achievements - 6 achievement tiers to unlock
- ๐ Live Events - Real-time event feed and notifications
- ๐ญ Farcaster - Profile display, sharing, auto-cast
- โก Fast - ~30-60s VRF fulfillment
- ๐ Secure - OpenZeppelin security standards
- ๐ฐ Fair - 95% payout, 5% platform fee
- ๐ฑ Mobile - Fully responsive design
- Solidity 0.8.28
- Foundry (forge, cast, anvil)
- Chainlink VRF v2.5 (provable randomness)
- OpenZeppelin (security standards)
- Base Network (Ethereum L2)
- Next.js 15.5.4 (App Router)
- React 19.1.1
- TypeScript 5.9.3 (strict mode)
- TailwindCSS 4.1.13
- Framer Motion 12.23.22
- wagmi 2.17.5 + viem 2.37.9
- Reown AppKit 1.8.8 (WalletConnect)
- Neynar SDK 3.34.0 (Farcaster)
- Turborepo 2.5.8 (monorepo)
- Vercel (deployment)
- BaseScan (verification)
flip-battle/
โโโ contracts/ # Smart contracts (Foundry)
โ โโโ src/ # Contract source files
โ โ โโโ FlipBattle.sol # Core betting logic
โ โ โโโ StreakManager.sol # Daily streaks
โ โ โโโ ReferralSystem.sol # Referral tracking
โ โ โโโ DailyFreeFlip.sol # Free daily flip
โ โโโ test/ # 70 tests (all passing)
โ โโโ script/ # Deployment scripts
โ โ โโโ Deploy.s.sol # Main deployment
โ โ โโโ DeployLocal.s.sol # Local testing
โ โโโ deploy-sepolia.sh # Interactive deployment
โ โโโ test-contracts.sh # Contract testing tool
โ โโโ foundry.toml # Foundry config
โ
โโโ apps/web/ # Next.js frontend
โ โโโ app/
โ โ โโโ components/ # 13 React components
โ โ โโโ hooks/ # 28 custom hooks
โ โ โโโ lib/ # Config & utilities
โ โ โโโ games/ # Games list page
โ โ โโโ profile/ # Profile page
โ โ โโโ page.tsx # Home page
โ โโโ public/
โ โ โโโ .well-known/
โ โ โโโ farcaster.json # Mini app manifest
โ โโโ package.json
โ
โโโ DEPLOYMENT_CHECKLIST.md # Step-by-step deployment
โโโ VERCEL_DEPLOYMENT.md # Vercel-specific guide
โโโ TESTING_GUIDE.md # Test scenarios
โโโ TEST_USDC_GUIDE.md # Get testnet USDC
โโโ PROJECT_STATUS.md # Current status
โโโ README.md # This file
- Node.js 18+ or Bun 1.2+
- Foundry (for contracts)
- Git
# Clone repository
git clone https://github.com/yourusername/flip-battle.git
cd flip-battle
# Install dependencies
bun install
# Build everything
bun run buildFrontend:
cd apps/web
bun run dev
# Open http://localhost:3000Contracts:
cd contracts
# Run tests
forge test
# Local deployment (Anvil)
make deploy-localSee: DEPLOYMENT_CHECKLIST.md for complete step-by-step guide
Quick version:
-
Get Prerequisites:
- Base Sepolia ETH (0.1+ ETH)
- VRF subscription (2+ LINK)
- BaseScan API key
- WalletConnect Project ID
-
Deploy Contracts:
cd contracts ./deploy-sepolia.sh -
Add VRF Consumers at https://vrf.chain.link
-
Update Vercel Env Vars with contract addresses
-
Deploy Frontend:
cd apps/web vercel --prod -
Test Everything - See
TESTING_GUIDE.md
Core coin flip betting contract with Chainlink VRF integration.
Key Functions:
createFlip(opponent, amount, choice)- Create challengeacceptFlip(gameId)- Accept challengecancelFlip(gameId)- Cancel before acceptanceclaimWinnings(gameId)- Claim prize after win
Events:
FlipCreated,FlipAccepted,FlipResolved,FlipCancelled
Daily check-in system with milestone rewards.
Milestones:
- Day 7: 5 USDC
- Day 14: 12 USDC
- Day 30: 30 USDC
- Day 60: 75 USDC
- Day 90: 150 USDC
Referral tracking and earnings.
Rewards:
- 1 USDC signup bonus
- 5% of all referral bets
Free daily flip lottery funded by platform fees.
Details:
- Free entry (only gas)
- 2% of platform fees go to prize pool
- One play per 24 hours
cd contracts
# Run all tests
forge test
# With gas report
forge test --gas-report
# Specific test
forge test --match-test testCreateFlip -vvvStatus: 70/70 tests passing โ
cd apps/web
# Build
bun run build
# Type check
bun run type-check
# Lint
bun run lintStatus: Build passing โ
- DEPLOYMENT_CHECKLIST.md - Complete deployment guide
- VERCEL_DEPLOYMENT.md - Vercel-specific deployment
- TESTING_GUIDE.md - Test scenarios
- TEST_USDC_GUIDE.md - Get testnet USDC
- PROJECT_STATUS.md - Current project status
- Frontend README - Frontend documentation
- Connect Wallet via WalletConnect
- Get USDC (testnet or mainnet)
- Create Challenge:
- Enter opponent address
- Choose bet amount (1+ USDC)
- Select Heads or Tails
- Wait for Acceptance or accept pending challenges
- Coin Flip - Chainlink VRF determines winner in ~60s
- Winner Claims - 95% of pot goes to winner
Bonus Features:
- Daily check-ins for streak rewards
- Refer friends for bonuses
- Free daily flip lottery
- Smart contract development
- Frontend development
- Testing & documentation
- Deployment scripts
- Testnet deployment
- Testing & bug fixes
- Mainnet preparation
- Launch! ๐
- Multiplayer tournaments
- NFT rewards for achievements
- DAO governance
- Mobile app
- 5% of all flip bets
- 2% to daily free flip prize pool
- 3% to operations and rewards
- Streaks: Pre-funded reward pool
- Referrals: Paid from platform fees
- Daily Free Flip: Funded by 2% of fees
- OpenZeppelin contracts for security standards
- Chainlink VRF for provable randomness
- ReentrancyGuard on all state-changing functions
- 70 unit tests covering all functionality
- Recommended: Security audit before mainnet
- Base Docs: https://docs.base.org
- Chainlink VRF: https://docs.chain.link/vrf
- Base Discord: https://discord.gg/buildonbase
- WalletConnect: https://docs.walletconnect.com
# Deploy contracts
cd contracts && ./deploy-sepolia.sh
# Test contracts
cd contracts && forge test
# Build frontend
cd apps/web && bun run build
# Deploy frontend
vercel --prodContributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
forge testandbun run build - Submit a pull request
MIT License - see LICENSE file for details
Built with:
- Base - Ethereum L2 network
- Chainlink - VRF randomness
- WalletConnect - Wallet connections
- Farcaster - Social integration
- Vercel - Hosting platform
Ready to flip? ๐ช
See DEPLOYMENT_CHECKLIST.md to get started!