All projects

mask-prediction

Privacy-preserving prediction market with commit-reveal betting and AI-powered settlement via Chainlink CRE.

Prediction Markets Privacy Risk & Compliance

What it is

Full Project Description
What it is: Private Prediction Market (PPM) is a decentralized prediction market where users can place bets on real-world outcomes (e.g., "Will ETH be above $5,000 by June 1, 2025?") without revealing their positions upfront. Bets are hidden using a cryptographic commit-reveal scheme, and market outcomes are automatically settled by a Gemini AI agent orchestrated through Chainlink's Compute Resource Engine (CRE).
How it works:

  1. A market creator posts a question via an HTTP trigger to the CRE workflow. The question is stored on-chain via a Solidity smart contract deployed on Sepolia.
  2. Participants submit a cryptographic hash (commitment) of their prediction + a secret salt, locking in ETH as a stake — without anyone seeing what they bet.
  3. After the deadline, anyone can call requestSettlement(), which emits an on-chain event.
  4. The CRE workflow listens for this event via a Log trigger, fetches the market question, and calls the Gemini AI API to determine the outcome (YES/NO).
  5. The AI's verdict is written back on-chain via CRE's EVM write capability, settling the market.
  6. Participants then reveal their hidden bets. Winners claim their ETH share proportionally; incorrect bets forfeit their stake.
    Problem it solves: Traditional on-chain prediction markets are fully transparent — anyone can see how others are betting before the market closes, which creates front-running, herd behavior, and manipulation. PPM solves this by keeping bets private until resolution, creating a fairer market. It also removes the need for human oracles or manual settlement by using AI via Chainlink CRE, making the entire lifecycle trustless and automated.

How it Works

The stack has three layers:
Smart Contracts (Solidity + Foundry) The core contract manages the full lifecycle of a prediction market: market creation, bet commitment (commit phase), AI-triggered settlement, bet revelation (reveal phase), and ETH claim distribution. It's deployed on Sepolia testnet and can also be tested on Tenderly Virtual TestNet for time-travel debugging.
Chainlink CRE Workflow (TypeScript) Two triggers are defined in workflow/src/workflow.ts:

  • HTTP Trigger — accepts a JSON payload to create a new market on-chain using CRE's EVM write capability.
  • Log Trigger — listens for SettlementRequested events on-chain, then fetches the question, calls Gemini AI (workflow/src/gemini.ts) via CRE's HTTP capability, and writes the AI verdict back to the contract.
    The workflow is configured via project.yaml (CRE project manifest), config.staging.json (network/contract config), and secrets.yaml (API key references).
    AI Settlement (Google Gemini) The gemini.ts module sends the market question to Gemini and parses a YES/NO response. This acts as a decentralized AI oracle for outcome resolution.

Links

Created by

  • sparsh