Privacy-preserving prediction markets with multi-model AI resolution, powered by Chainlink CRE.
Chainlink Convergence Hackathon 2026
Track
Prize
Our Approach
Prediction Markets
$16K
Parimutuel markets with commit-reveal privacy, time-weighted shares, and principal protection
Privacy
$16K
Confidential HTTP for secret AI key handling in CRE secure enclaves
CRE & AI
$17K
Multi-model AI consensus (OpenAI GPT-4o-mini + Gemini 2.0 Flash) via CRE workflow
thirdweb x CRE
Plans
thirdweb SDK for wallet connect, contract reads/writes
User (Browser)
|
v
Frontend (Next.js 16 + thirdweb SDK)
|-- Markets board with live on-chain data
|-- Trade ticket: commit-reveal betting flow
|-- Create market form
|
v
Smart Contracts (Sepolia)
|-- MarketFactory.sol Deploy new prediction markets with duration
|-- PrivateMarket.sol Parimutuel betting + time-weighted shares + principal protection
|-- CREConsumer.sol ReceiverTemplate -> forwards CRE reports to markets
|-- MockUSDC.sol Test payment token (6 decimals)
|
v
CRE Workflow (private-predict)
|-- main.ts Log trigger: listens for SettlementRequested events
|-- ai-resolver.ts Queries OpenAI + Gemini via Confidential HTTP
|-- evm.ts Encodes report, signs with ECDSA, submits on-chain
Anyone creates a market with a question and duration (5 min to 30 days).
Users commit private bets (YES/NO direction hidden via keccak256 hash).
Early bettors get 1.0x shares; late bettors decay to 0.2x (time-weighted).
1% fee deducted on each bet.
Market closes. Bettors reveal within 24h.
Anyone calls requestSettlement() -> emits SettlementRequested event.
CRE workflow detects the event via EVM log trigger.
Workflow queries both Gemini and OpenAI via Confidential HTTP .
API keys injected inside CRE enclave (never in code/logs).
Both models return YES/NO/INCONCLUSIVE with confidence (0-10000).
Multi-model consensus: both must agree or result is INCONCLUSIVE.
Signed report submitted to CREConsumer.onReport() -> PrivateMarket.resolveFromOracle().
Winners claim payouts: principal protection (deposit back) + share of losing pool.
Commit-reveal betting : Directions hidden until reveal. Commitment = keccak256(sender, predictedYes, salt, amount, marketAddress).
Confidential HTTP : AI API keys stored in CRE vault secrets, injected at runtime inside secure enclaves.
Minimum bet : 1 USDC floor prevents dust analysis.
Reveal deadline : 24-hour window prevents indefinite exposure.
Unrevealed recovery : Miss the window? Reclaim full deposit via reclaimUnrevealed().
Parimutuel Model (Inspired by Pumpcade)
Time-weighted shares : First 10% of duration = fair launch (1.0x multiplier). Then linear decay to 0.2x.
Principal protection : Winners always get their net deposit back, plus proportional share of the losing pool.
1% fee : Deducted before shares calculation. Owner can withdraw accumulated fees.
private-prediction-market/
|-- contracts/
| |-- src/
| | |-- CREConsumer.sol ReceiverTemplate implementation
| | |-- PrivateMarket.sol Market logic with commit-reveal + time-weighted shares
| | |-- MarketFactory.sol Factory with duration validation (5min - 30 days)
| | |-- MockUSDC.sol Test ERC-20 token
| | |-- interfaces/ CRE receiver interfaces
| |-- test/
| | |-- MarketFactory.ts 8 tests covering full lifecycle
| |-- script/
| |-- deploy.ts Deployment script
| |-- create-market.ts Market creation script
|
|-- cre-workflow/
| |-- project.yaml RPC endpoints
| |-- secrets.yaml API key mappings (OPENAI_API_KEY, GEMINI_API_KEY)
| |-- private-predict/
| |-- workflow.yaml Workflow config
| |-- config.json Runtime config (models, chain, addresses)
| |-- main.ts Log trigger + handler entry point
| |-- ai-resolver.ts Multi-model AI via Confidential HTTP
| |-- evm.ts Report encoding + on-chain write
| |-- types.ts Zod schemas + TypeScript types
| |-- package.json @chainlink/cre-sdk 0.0.8-alpha
|
|-- frontend/
|-- app/ Next.js 16 pages (markets, market detail, create, portfolio)
|-- components/ React components (trade ticket, evidence panel, etc.)
|-- lib/ On-chain reads, ABI definitions, commitment hashing
All CRE workflow files are in cre-workflow/private-predict/ :
File
Purpose
main.ts
Entry point: EVM log trigger for SettlementRequested, handler calls AI + submits report
ai-resolver.ts
Confidential HTTP requests to OpenAI + Gemini, multi-model consensus aggregation
evm.ts
ABI-encodes settlement report, signs with ECDSA/keccak256, writes via EVMClient.writeReport()
types.ts
Zod config schema, AI response validation, TypeScript types
config.json
Runtime config: model names, chain selector, market addresses, consumer address
workflow.yaml
Workflow name, artifact paths
../project.yaml
RPC endpoints for Sepolia
../secrets.yaml
Secret name mappings for vault
Node.js 18+ and Bun
CRE CLI (curl -sSL https://cre.chain.link/install.sh | bash)
Sepolia testnet ETH
API keys: OpenAI, Gemini
thirdweb client ID
# Contracts
cd contracts
npm install
npx hardhat compile
npx hardhat test # 8 tests pass
npx hardhat run script/deploy.ts --network sepolia
# CRE Workflow
cd cre-workflow/private-predict
bun install # runs cre-setup postinstall
cre login # authenticate with CRE
# Set API keys for simulation
export OPENAI_API_KEY_VAR=sk-...
export GEMINI_API_KEY_VAR=AIza...
# Simulate workflow (needs a SettlementRequested tx hash)
cre workflow simulate private-predict --target local-simulation
# Frontend
cd frontend
npm install
npm run dev # http://localhost:3000
# .env (root)
SEPOLIA_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
PRIVATE_KEY=0x...
NEXT_PUBLIC_FACTORY_ADDRESS=0x...
NEXT_PUBLIC_CRE_CONSUMER_ADDRESS=0x...
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=...
NEXT_PUBLIC_CHAIN_ID=11155111
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=AIza...
Function
Description
createMarket(question, duration)
Deploy a new market (duration: 5min - 30 days)
getMarkets(offset, limit)
Paginated market address list
totalMarkets()
Count of deployed markets
Function
Description
placeBet(commitment, amount)
Commit encrypted bet (min 1 USDC, 1% fee)
calculateShares(netAmount)
View time-weighted share calculation
revealBet(predictedYes, salt)
Reveal within 24h after close
requestSettlement()
Emit SettlementRequested for CRE
claimPayout()
Claim winnings (principal + share of losers)
claimRefund()
Full refund if market cancelled
reclaimUnrevealed()
Reclaim if reveal window missed
getPotentialPayout(bettor)
View expected payout
Function
Description
onReport(metadata, report)
CRE entry point (forwarder only)
Deployed Contracts (Sepolia)
8 tests covering the full market lifecycle:
PrivatePredict core contracts
✓ creates a market with duration and pays winner with principal protection
✓ applies time-weighted shares correctly (early vs late bettor)
✓ rejects onReport from non-forwarder address
✓ rejects bets below minimum amount
✓ returns full amount (including fee) when market is cancelled
✓ assigns sequential market IDs
✓ rejects invalid durations
✓ allows fee withdrawal by owner
Layer
Technology
Smart Contracts
Solidity 0.8.24, Hardhat, OpenZeppelin
CRE Workflow
TypeScript, @chainlink/cre-sdk 0.0.8-alpha, Zod
AI Models
OpenAI GPT-4o-mini, Google Gemini 2.0 Flash
Frontend
Next.js 16, React 19, thirdweb SDK
Chain
Ethereum Sepolia Testnet
MIT