All projects

CResolver

AI agents resolve prediction markets via CRE workflow with ERC-8004 identity and BFT consensus

Prediction Markets CRE & AI Privacy

What it is

Prediction markets have a resolution problem. In March 2025, a single UMA whale with 25% of the voting power forced a $7 million Polymarket market to resolve incorrectly, and Polymarket refused to refund anyone. Token-weighted voting doesn't work for resolution: whoever has the most tokens controls the truth.

CREsolver replaces token voting with AI agent investigation. Instead of asking token holders to click a button, we use autonomous AI agents that actually research the question, defend their evidence under challenge, and reach BFT consensus on the answer.
How it works:

  1. A prediction market is created on-chain with a question and an ETH reward pool.
  2. AI agents join as workers. Each one has a verified on-chain identity via ERC-8004 and stakes ETH to participate (real skin in the game).
  3. When the deadline passes, anyone can call requestResolution(). This emits an on-chain event that triggers a Chainlink CRE workflow.
  4. The CRE workflow runs inside a DON TEE and executes a 6-step pipeline:
    • READ: Reads market data and worker info from chain
    • ASK: Each agent independently researches the question (POST /a2a/resolve)
    • CHALLENGE: The workflow challenges each agent to defend their evidence (POST /a2a/challenge)
    • EVALUATE: An LLM (via Confidential HTTP with DON Vault secrets) evaluates each agent across 8 quality dimensions, aggregated to 3 on-chain reputation scores
    • CONSENSUS: BFT weighted majority, at least 2 out of 3 agents must agree
    • WRITE: The result is written back on-chain as a DON-signed report
  5. On-chain: rewards are distributed proportional to quality, stakes are returned, and each agent's ERC-8004 reputation is updated publicly.
  6. Users settle bets and claim winnings via the BinaryMarket companion contract. The settler earns a 1% fee as incentive.

The key difference from UMA: no token voting, no whale attacks. Agents earn trust through accuracy over time, and their reputation is public, on-chain, and portable across protocols via ERC-8004.

How it Works

Smart Contracts (Solidity + Foundry):

  • CREsolverMarket.sol: Market creation, agent joining (with ERC-8004 authorization gates), resolution, reward distribution, and on-chain reputation updates
  • CREReceiver.sol: Contract that receives DON-signed reports (implements required interface) from the CRE workflow and calls resolveMarket()
  • BinaryMarket.sol: Companion betting contract for YES/NO positions with settle and claim mechanics

CRE Workflow:

  • 6-step resolution pipeline compiled to WASM for execution inside the Chainlink DON
  • Dual triggers: EVM Log Trigger (production:fires on requestResolution() event) / HTTP Trigger (in case resolutions need to be called through HTTP)
  • Uses CRE SDK's EVMClient for on-chain reads/writes, HTTPClient for agent queries, and ConfidentialHTTPClient for LLM evaluation
  • BFT quorum enforcement: requires ceil(2n/3) agent responses before proceeding
  • LLM evaluation via Confidential HTTP, API key injected from DON Vault using template syntax, never appears in code or logs

AI Agents (Cloudflare Workers):

  • A2A protocol endpoints: /a2a/resolve (investigation) and /a2a/challenge (defense)
  • Each agent has an ERC-8004 on-chain identity with tokenURI containing service endpoints for runtime discovery

ERC-8004 Integration:

  • IdentityRegistry: Agent registration, tokenURI with registration-v1 metadata, EIP-712 wallet binding via setAgentWallet()
  • ReputationRegistry: Multi-dimensional reputation (resolution quality, source quality, analysis depth) written per resolution via giveFeedback()
  • Authorization gates: isAuthorizedOrOwner() ensures only registered agents can join markets
  • On-chain endpoint discovery: CRE workflow reads tokenURI to find each agent's A2A endpoint at runtime

Frontend (Next.js + viem + TailwindCSS):

  • Live dashboard on Sepolia, markets, betting, agent reputation, worker panels
  • Wallet connection for betting (YES/NO), joining markets, and triggering resolution
  • Real-time ETH/USD conversion via CoinGecko

Testing:

  • Full E2E suite: Docker Compose (Anvil + 3 agents) with Vitest — 18 integration tests
  • CRE workflow simulation via CLI against Sepolia (real agents) and mock mode

Links

Created by

  • Gilberts Ahumada