All projects

OracleSettler

Trustless prediction markets with autonomous CRE settlement — dual-source consensus, AI judgment, dispute arbitration, and cross-contract parlays. Zero backend.

Prediction Markets CRE & AI DeFi & Tokenization Privacy World

What it is

No Express, no PostgreSQL, no cron jobs — OracleSettler is a fully autonomous prediction market platform where Chainlink CRE replaces the entire backend server stack. The CRE workflow IS the backend.

THE PROBLEM:
Prediction markets like Polymarket do $500M+ in daily volume, but settlement depends on a small group of human resolvers. If they're wrong or biased, users have zero recourse. This creates a single point of failure at the most critical moment — when money changes hands.

HOW IT WORKS:
OracleSettler uses 16 CRE capabilities across 5 trigger types to handle the complete market lifecycle autonomously:

  1. AI Market Creation — Users type a question in plain English ("Will Dogecoin hit $1 by summer?"). Gemini AI parses it, extracts the asset and target, and deploys on-chain via CRE HTTP Trigger.
  2. Dual-Source Price Consensus — CRE fetches prices from CoinGecko AND CryptoCompare via Confidential HTTP. If sources diverge >2%, settlement is rejected. If they agree and the price is >5% from target, settlement is instant. If borderline (<5%), Gemini AI makes the final judgment with a confidence score.
  3. Event Market Resolution — For non-price questions (e.g., "Will GPT-5 launch before July 2026?"), CRE routes to a completely different pipeline: Gemini AI with Google Search grounding researches real-world evidence and returns YES/NO with confidence.
  4. Dispute Arbitration — After settlement, a 1-hour dispute window opens. Anyone can challenge by staking 0.001 ETH. CRE re-runs the entire verification in strict mode (70% confidence threshold vs 60% normal). If the re-check overturns the result, the stake is refunded. If not, it's forfeited as anti-spam.
  5. Cross-Contract Parlay Settlement — Users combine 2-5 market predictions into combo bets. CRE orchestrates across two contracts: reads parlay state from ParlayEngine, cross-reads each leg's outcome from PredictionMarket, verifies all disputes are resolved, and writes settlement back. Contract A reads, Contract B writes — fully autonomous.
  6. Settle Preview + AI Advisor — Before settlement, users see real-time price data and a predicted outcome. An AI advisor compares market odds against its own probability estimate, identifies mispricing, and recommends BET YES, BET NO, or HOLD.

ARCHITECTURE:
Two Solidity contracts (PredictionMarket + ParlayEngine) with a single _processReport function that routes CRE reports by prefix byte: 0x00 creates, 0x01 settles, 0x02 resolves disputes, 0x03 settles parlays. World ID integration provides sybil-resistant market creation via zero-knowledge proof of unique humanness.

WHAT MAKES IT DIFFERENT:

  • Zero backend: CRE replaces Express, PostgreSQL, cron, price feeds, AI endpoints, and event indexing
  • Four resolution paths in one system: price consensus, AI event judgment, dispute arbitration, parlay settlement
  • 84 Foundry tests across 3 test suites
  • 9 live markets on Sepolia with real predictions
  • Fully verified contracts on Etherscan

How it Works

SMART CONTRACTS (Solidity 0.8.24, Foundry):

  • PredictionMarket.sol — Market creation, predictions, settlement, disputes, claims. Inherits Chainlink ReceiverTemplate. Single _processReport() routes CRE reports by prefix byte: 0x00 create, 0x01 settle, 0x02 dispute.
  • ParlayEngine.sol — Cross-contract combo bets. Accepts 0x03 prefix reports for parlay settlement. House-pool model with multiplied odds.
  • Both contracts verified on Sepolia Etherscan. 84 Foundry tests across 3 suites.
  • Deployed via Foundry scripts with deterministic addresses.

CRE WORKFLOW (TypeScript, Bun + CRE SDK):

  • 10 workflow modules, 5 trigger types, 16 capabilities total.
  • httpCallback.ts — HTTP Trigger for AI-powered market creation (Gemini parses natural language → on-chain deployment)
  • logCallback.ts — Log Trigger listens for SettlementRequested events → dual-source price fetch → consensus → settlement
  • disputeCallback.ts — Log Trigger for DisputeFiled events → strict re-verification (70% threshold)
  • cronCallback.ts — Cron Trigger every 6h for auto-settlement + auto-market creation from trending news
  • parlayCallback.ts — Log Trigger for ParlaySettlementRequested → cross-contract reads (ParlayEngine + PredictionMarket) → settlement report
  • settlementLogic.ts — Core consensus engine: CoinGecko + CryptoCompare Confidential HTTP, >2% divergence rejection, >5% direct settlement, <5% Gemini AI judgment
  • gemini.ts — Confidential HTTP to Gemini AI (price borderline analysis + event market resolution via Google Search grounding)
  • All workflows validated end-to-end via cre simulate --broadcast on Sepolia.

FRONTEND (React + TypeScript + Vite):

  • ethers.js for direct contract interaction (no backend API)
  • Settlement Explorer with step-by-step replay animation (1200ms/step)
  • Dispute Simulator with visual re-verification flow
  • AI Market Creation via Gemini (natural language → auto-fill form)
  • Settle Preview with real-time dual-source prices + AI Advisor (edge detection, mispricing alerts)
  • Parlay Builder with real-time odds multiplier
  • OddsChart with on-chain event replay
  • StatsBar pulling live on-chain data (markets, volume, settled count)
  • World ID integration for sybil-resistant market creation
  • Mock data fallback for RPC downtime
  • Deployed on Vercel: oracle-settler.vercel.app

TOOLING:

  • Foundry (contracts + tests + deployment)
  • Bun (CRE workflow runtime)
  • CRE CLI (simulate + broadcast)
  • Makefile for one-command build/test/deploy
  • .env.example for reproducibility

No backend server, no database, no hosted API. CRE is the entire backend.

Links

Created by

  • Yuxiang Jiang