Play fully on-chain with Color Game Tokens (CGT) via our new Game Dashboard.
Bet Color Game Tokens (CGT) on RED, GREEN, or VIOLET.
- RED/GREEN: 2x Multiplier
- VIOLET: 5x Multiplier (High Risk, High Reward)
Drop the ball down the peg pyramid. Watch it bounce into prize slots ranging from 0.2x to 1000x.
The game is live on Sepolia Testnet. Play right now — no installation required.
| Component | Link | Status |
|---|---|---|
| 🎮 Frontend | color-prediction-chain.vercel.app | 🟢 Online |
| ⚙️ Backend | color-prediction-chain.onrender.com | 🟢 Online |
| 🪙 Game Token (CGT) | 0xfDf4...7fe7A | 🟢 Active |
| 📜 Color Contract | 0x982A...1dD6 | 🟢 Active |
| 🔻 Plinko Contract | 0xbFE1...55fD | 🟢 Active |
The game is also available as a Flutter mobile app with full WalletConnect integration.
- WalletConnect v2: Connect securely with MetaMask or other mobile wallets
- Deep Linking: Seamless redirection back to the app after signing transactions
- Real-time Updates: Live game rounds and history
- Native Experience: Smooth performance on Android & iOS
- Flutter SDK installed
- An Android Emulator or physical device
-
Navigate to the mobile directory:
cd game-mobile -
Install dependencies:
flutter pub get
-
Run the app:
flutter run
- Tap the Wallet icon in the top right.
- Select MetaMask (or your preferred wallet).
- Approve the connection in your wallet app.
- The app will automatically reopen via the
colorprediction://deep link scheme.
Dev Note: The deep link scheme is configured in
android/app/src/main/AndroidManifest.xml. If you change it, remember to update theredirectUrlinWalletService.dart.
⏱️ Takes about 1 minute to start playing.
Click "Connect Wallet" on the game page. MetaMask will ask you to switch to the Sepolia Testnet and add a high-speed RPC endpoint. Approve both.
You need a tiny amount of ETH to pay for gas fees on transactions. Use one of these faucets to get it for free:
| Faucet | Link | Amount |
|---|---|---|
| Google Cloud (Fastest) | cloud.google.com/…/sepolia | 0.01 ETH |
| Alchemy | alchemy.com/faucets | 0.05 ETH |
| QuickNode | faucet.quicknode.com | 0.05 ETH |
💡 Tip: Click your wallet address in the top-left corner of the game to copy it instantly.
Click "🪙 Mint 1000 CGT" in the game. Confirm the MetaMask transaction. You now have 1,000 free Color Game Tokens to bet with.
Navigate to the Dashboard and choose your game.
- Pick a color:
- RED or GREEN (2x Payout)
- VIOLET (5x Payout)
- Enter bet amount (e.g.,
10 CGT). - Click "Place Bet".
- Winnings are sent automatically when the round ends (~30s).
- Set the risk level by choosing Rows (8, 12, or 16).
- More rows = Higher potential multiplier (up to 1000x).
- Enter bet amount.
- Click "Play" to drop a ball.
- Winnings are distributed instantly based on the slot the ball lands in.
| Feature | Description |
|---|---|
| 🪙 Custom ERC-20 Token | Bets use Color Game Token (CGT) — no real money at risk |
| 🔓 Public Minting | Anyone can mint tokens freely to play |
| 🎮 Multi-Game Support | Switch between Color Prediction and Plinko |
| 🤖 Automated Rounds | (Color Game) Backend resolves every round every 30 seconds |
| 📡 Robust RPC | Load-balanced public RPCs prevent rate-limiting |
| 📊 Real-time History | Supabase tracks every round result live |
| ⛓️ Trustless Payouts | Smart contract pays winners directly — no manual approval |
┌─────────────┐ Bets ┌──────────────────┐ Pays ┌──────────────┐
│ │ Tokens │ Smart Contract │ Tokens │ │
│ User / │──────────>│ (The House) │──────────>│ Winner's │
│ Frontend │ │ │ │ Wallet │
│ │ │ placeBet() │ │ │
└──────┬──────┘ │ resolveRound() │ └──────────────┘
│ └────────┬──────────┘
│ │
│ Views History │ Resolves Round
▼ ▼
┌─────────────┐ ┌──────────────────┐
│ Supabase │<──────────│ Game Backend │
│ DB │ Updates │ (The Brain) │
│ │ Stats │ 30s Round Timer │
└─────────────┘ └──────────────────┘
Data Flow:
- User places bet → Frontend calls
placeBet()→ Tokens locked in contract - 30 seconds pass → Backend detects round end → Generates result
- Backend calls
resolveRound()→ Contract pays all winners instantly - Backend logs result → Supabase updated → Frontend shows live history
| Layer | Technology |
|---|---|
| ⛓️ Blockchain | Ethereum — Sepolia Testnet |
| 📜 Smart Contracts | Solidity 0.8.20 + OpenZeppelin (ERC-20) |
| 🔧 Dev Framework | Hardhat |
| 🌐 Frontend | HTML, CSS, JavaScript, ethers.js, React, Vite |
| 📱 Mobile | Flutter (Dart), WalletConnect v2 |
| 🤖 Backend | Node.js, Express |
| 🗄️ Database | Supabase (PostgreSQL) |
| 🦊 Wallet | MetaMask |
color-prediction-chain/
│
├── contracts/
│ ├── ColorPrediction.sol # Main game logic (bets, payouts, rounds)
│ └── GameToken.sol # ERC-20 token contract (CGT)
│
├── game-frontend/
│ ├── index.html # Game UI
│ ├── src/ # React components & logic
│ └── vite.config.js # Build configuration
│
├── game-mobile/
│ ├── lib/ # Flutter source code
│ ├── android/ # Android native configuration
│ └── pubspec.yaml # Dart dependencies
│
├── game-backend/
│ ├── index.js # Express server entry point
│ ├── roundEngine.js # Core game loop (30s timer + resolution)
│ ├── supabaseClient.js # Supabase connection
│ ├── .env # Config (never committed!)
│ └── package.json
│
├── scripts/
│ └── deploy.js # Deploys GameToken + ColorPrediction + funds house
│
├── hardhat.config.js # Hardhat network configuration
├── START_ALL.bat # One-click local launcher (Windows)
├── .gitignore # Excludes .env, node_modules, artifacts
└── README.md # This file
Want to run this on your own machine? Follow these steps.
git clone https://github.com/deeps00007/color-prediction-chain.git
cd color-prediction-chainnpm install
cd game-backend && npm install && cd ..Windows:
START_ALL.batThis automatically:
- ✅ Starts a local Hardhat blockchain
- ✅ Deploys both contracts (GameToken + ColorPrediction)
- ✅ Funds the house with 50,000 CGT
- ✅ Starts the game backend
- Open
game-frontend/index.htmlin your browser - Switch MetaMask to Localhost 8545 network
- Import a Hardhat test account (copy private key from the Hardhat terminal)
- Mint tokens and start betting
All settings live in game-backend/.env:
# Blockchain
RPC_URL=http://127.0.0.1:8545 # Local development
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/... # Sepolia testnet
PRIVATE_KEY=0x... # Deployer wallet key
# Contracts (updated after deployment)
CONTRACT_ADDRESS=0x...
TOKEN_ADDRESS=0x...
# Game
ROUND_DURATION_SECONDS=30
# Database
SUPABASE_URL=https://...
SUPABASE_SERVICE_KEY=eyJ...| Problem | Solution |
|---|---|
| "Transaction reverted" | Reset MetaMask activity: Settings → Advanced → Clear Activity Tab Data |
| Balance shows 0 CGT | Click "Mint 1000 CGT" and confirm in MetaMask |
| Rounds not progressing | Check that the backend server is running and .env has correct addresses |
| "Insufficient funds" for gas | Get free Sepolia ETH from a faucet (see How to Play) |
| Contract shows empty | Fund the house: npx hardhat run scripts/deploy.js --network localhost |
| Can't connect wallet | Make sure MetaMask is unlocked and you're on the correct network |
This is a Testnet / Educational project. Be aware of the following:
| Limitation | Details |
|---|---|
| 🎲 Centralized Randomness | Results are generated by the backend, not Chainlink VRF |
| 🪙 Infinite Minting | Anyone can mint unlimited CGT tokens |
| 🏗️ No Audit | This contract has not been professionally audited |
For production, these would need to be addressed: integrate Chainlink VRF for verifiable randomness, remove public minting, add a professional security audit, and implement emergency pause mechanisms.
Contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for details.
Built with by Deepanshu Singh