PredictChain
AI-powered decentralized sports prediction market built on Chainlink CRE & Ethereum.
What it is
Sports Prediction Market — Full Project Description
What is it?
Sports Prediction Market is a decentralized application (dApp) built on Ethereum that lets anyone create and participate in binary prediction markets around real-world sports events — such as "Will Arsenal beat Chelsea on April 12th?" Users stake ETH on a Yes or No outcome, and the winning side splits the entire pool proportionally to their bets.
What makes it unique is that the entire lifecycle — from market creation to settlement — is automated by a Chainlink CRE (Compute Runtime Environment) workflow, eliminating the need for any trusted human operators or centralized APIs.
How it works?
- Create — A user submits a sports prediction question and a deadline via the web frontend. The Chainlink CRE workflow receives this via HTTP trigger, encodes it, gets it signed by Chainlink's Decentralized Oracle Network (DON), and writes it directly to the smart contract on Ethereum Sepolia.
- Predict — Other users browse open markets and stake ETH on Yes or No before the deadline. Funds are pooled separately for each side.
- Settle — After the deadline, anyone can trigger settlement. This fires an on-chain event that the CRE workflow's log trigger picks up. The workflow then:
- Calls Gemini AI to parse the question into structured game details (teams, sport, league, date)
- Fetches the real match result from ESPN's public scoreboard API
- Sends both to Gemini AI again to determine the outcome (Yes/No) with a confidence score
- Signs the settlement report via DON consensus and writes it back to the contract
- Claim — Winners call claim() and receive their proportional share of the total ETH pool.
What problem does it solve?
Traditional prediction markets suffer from three major issues:
- Manual settlement — Someone has to manually resolve markets, introducing trust issues and delays
- Centralized data sources — Most platforms rely on a single API or team to report outcomes, which can be manipulated or go offline
- High complexity — Integrating off-chain data with on-chain logic usually requires paying oracle node operators or running custom infrastructure
This project solves all three: settlement is fully autonomous (triggered by the contract itself), sports data comes from a public zero-config API (ESPN), and the AI layer (Gemini) removes the need for rigid hand-coded outcome logic — it can understand natural language questions about any sport, team, or match format. The DON-signed reports ensure that no single party can fake a settlement result.
How it Works
How is it built?
The project is made up of three layers:
- Smart Contract — Solidity + Foundry
The core logic lives in
SportsPredictionMarket.sol, written inSolidity 0.8.24and built withFoundry. It inherits from Chainlink'sReceiverTemplatebase contract, which handles DON report verification. All on-chain state (markets, bets, pools, settlements) is managed here. Deployed onEthereum Sepolia.2. Off-Chain Automation — Chainlink CRE + TypeScript
The automation layer is a Chainlink CRE workflow written in TypeScript using the
- @chainlink/cre-sdk. It registers two triggers:HTTP Trigger — listens for market creation requests, ABI-encodes the data, gets a DON-signed report, and calls the contract
- Log Trigger — watches for SettlementRequested events on-chain, then runs the full AI pipeline:
- Gemini 2.0 Flash parses the natural language question into structured game data
- ESPN's public scoreboard API returns the real match result (no API key needed)
- Gemini again determines the Yes/No outcome with a confidence score
- The signed settlement report is written back to the contract
- Frontend — Next.js + thirdweb + Radix UI
The user interface is built with Next.js 16 (App Router) and React 19. Wallet connection and all contract interactions use thirdweb v5 SDK. UI components come from Radix UI with Tailwind CSS for styling and Framer Motion for animations.
LayerTechSmart ContractSolidity, Foundry, Ethereum SepoliaOracle / AutomationChainlink CRE, TypeScript, cre-sdkAIGoogle Gemini 2.0 FlashSports DataESPN Scoreboard APIFrontendNext.js 16, React 19, thirdweb v5UIRadix UI, Tailwind CSS, Framer Motion
Links
Created by
- Wilfred Adzer