ETH price in next 1 hour prediction game. Compete against AI and other players. Win ETH rewards
Predictron Arena is a fully decentralized prediction market where players bet on ETH price movements in hourly rounds. Players compete against each other and an AI oracle by predicting whether the price will go UP or DOWN, creating an engaging blockchain gaming experience powered entirely by Chainlink's oracle infrastructure.
The game operates on a unique two-round system enabling continuous gameplay. In the betting phase, players place bets on the upcoming round before it starts - they can bet any amount of ETH on UP or DOWN, place multiple bets, or hedge by betting on both sides. An AI oracle powered by Chainlink Functions and CloudFlare AI makes its prediction first, creating strategic depth: do you trust the AI or bet against it? When a round starts automatically via Chainlink Automation, the starting ETH/USD price is captured from Chainlink Price Feeds and betting closes. The round runs for one hour while players watch real-time price movements, and betting is already open for the next round. When the round ends, the final price determines winners - if price went up, UP bets win; if down, DOWN bets win. Winners split the entire betting pool proportionally based on bet sizes minus a 2% protocol fee.
Key innovations: First prediction game with verifiable on-chain AI predictions alongside humans. Completely trustless operation with no central authority. Non-stop action via the two-round system. Full transparency with all bets, prices, and results on-chain. Instant reward visibility when rounds end. Advanced Envio HyperIndex backend provides sub-100ms query times and immediate reward calculations. Modern React frontend with real-time analytics, dark/light themes, and public analytics dashboard. Production deployment on Vercel with verified contracts on Sepolia.
The project showcases how Chainlink Price Feeds, Automation, and Functions can work together to create entirely new categories of decentralized applications. By eliminating centralization, manual intervention, and questionable price feeds found in traditional prediction markets, Predictron Arena delivers a fair, transparent, and fully automated prediction game that runs 24/7.
Tech Stack: Solidity smart contracts built with Foundry and OpenZeppelin security libraries. Ethereum Sepolia testnet deployment with verified contracts. Triple Chainlink integration: Price Feeds for ETH/USD data, Automation for round management, and Functions for AI predictions via CloudFlare AI. Envio HyperIndex for blockchain indexing with TypeScript event handlers, PostgreSQL database, and Hasura GraphQL API. React 18 frontend with TypeScript, Vite, ethers.js v6, Apollo Client, Tailwind CSS, and Recharts for data visualization. Production hosting on Vercel and Envio Cloud.
Smart Contract Architecture: The PredictronArena.sol contract maintains two parallel round states - currentRoundId for the active round and nextRoundId accepting bets. This dual-state design enables continuous gameplay. The placeBet function only accepts bets on nextRoundId with validation. The startRound function triggered by Chainlink Automation moves nextRoundId to currentRoundId, captures starting price from Price Feeds, and prevents further betting. The endRound function captures final price after one hour, determines winners based on price direction, and enables proportional reward claims. Reward calculation: user's winning bet divided by total winning bets, multiplied by total pool, minus 2% protocol fee. All protected by ReentrancyGuard and Pausable mechanisms.
Chainlink Integration Excellence: Implemented AutomationCompatibleInterface with custom logic where checkUpkeep returns true when 3300 seconds elapsed, and performUpkeep first calls Chainlink Functions to fetch AI prediction from CloudFlare AI API, then handles round transitions by ending current round if needed and starting new round with AI prediction. The Functions source code makes HTTP requests to CloudFlare AI, parses UP/DOWN predictions, and returns results to the contract. All predictions stored on-chain via ExternalPredictionAdded events.
Backend Sophistication: Built advanced Envio HyperIndex indexing layer to solve slow RPC queries and provide instant reward calculations. Defined comprehensive GraphQL schema with Round, UserRound, User, GlobalStats, and AiStats entities. Created TypeScript event handlers processing RoundStarted, BetPlaced, RoundEnded, RewardClaimed, and ExternalPredictionAdded in real-time. Implemented sophisticated reward calculation logic that runs immediately when rounds end rather than lazily. Handles complex scenarios: users hedging by betting both UP and DOWN, multiple bets per round, gross rewards vs net P&L calculations. Maintains participant lists per round ensuring all users get immediate reward calculations. Enables split display where frontend shows separate entries for UP and DOWN bets in same round.
Frontend Polish: Built production-ready React application with three main tabs. PlayTab displays current round with live countdown timer, next round betting interface with UP/DOWN buttons, AI prediction visibility, real-time pool sizes, and transaction feedback. DashboardTab merged history and stats showing paginated betting history with separate entries for hedged bets, win/loss status, price visualizations, claimable rewards section, leaderboard, and AI performance metrics. AnalyticsTab showcases Envio's speed with live query performance metrics, auto-refresh toggle, protocol overview, recent activity feed, and interactive charts for round results, bet distribution, pool trends, user participation, ETH price history, and bet side trends - all publicly accessible without wallet connection. Implemented Web3Context managing MetaMask integration, automatic account switching detection, and optimistic UI updates. Used Apollo Client for efficient GraphQL queries with network-only fetch policy. Responsive design with dark/light theme support and clean sci-fi web3 aesthetic.
Challenges and Solutions: Handling MetaMask rate limiting by removing auto-refresh from PlayTab and using explicit gas limits. Synchronizing frontend-backend data by prioritizing backend indexer as source of truth for round states. Implementing accurate win/loss calculations based on net P&L rather than gross rewards to properly handle hedged positions. Ensuring X-axis labels display all batches in charts by setting interval to 0 in Recharts. Calculating stats only from ended rounds to prevent showing inflated returns from pending bets. The production deployment demonstrates a fully functional prediction market with real automated players generating activity 24/7, verified smart contracts on Etherscan, and sub-second query performance via Envio's hosted infrastructure.

