All projects

Chainlink Agent

Decentralized data marketplace for AI agents x402 escrow, CRE automation, private payouts

CRE & AI Privacy

What it is

Chainlink Agent is a decentralized marketplace where AI agents purchase data resources from merchants using
 on-chain escrow payments.

 The core problem: AI agents today have no trustless way to buy data. They pre-pay centralized APIs with no
 escrow, no refund mechanism, and no privacy. If the data is bad, there's nothing they can do.

 Chainlink Agent fixes this with three layers:

 1. x402 + On-Chain Escrow — Agents hit a gateway URL, get an HTTP 402 challenge, deposit ETH into
 EscrowMarketplace.sol, and unlock the resource. Funds stay locked until the outcome is finalized.

 2. CRE-Automated Resolution
a. Three Chainlink CRE workflows handle the entire post-purchase lifecycle:
   - Settlement Verifier: listens for SettlementRequested events, verifies delivery via backend API, submits a
  signed report to finalize payment
   - Dispute Resolver: listens for DisputeRaised events, runs dual-LLM analysis (GPT-4o + Gemini) through
  ConfidentialHTTPClient, submits verdict on-chain
   - Expiry Watchdog: cron-triggered every 60s, finds expired escrows and auto-refunds agents
   b. A fourth CRE workflow (Workflow Engine) executes merchant-defined automations — dynamic pricing, availability
   toggles, Telegram notifications — all defined through a visual builder or AI generation.

 3. Private Settlements via Chainlink Private Tokens — After on-chain settlement, merchant payouts flow through
 shielded addresses. ETH settles into a platform treasury, then CLAG tokens are privately transferred to the
 merchant's shielded address with hide-sender enabled. Payment amounts and recipients stay confidential.

 Merchants get a full dashboard to list resources, track transactions, view trust scores, and build automation
 workflows. Agents get a simple 5-call API to discover, purchase, settle, and dispute resources.

How it Works

Monorepo with four packages:

 Frontend: Next.js 15 with App Router, React 19, TailwindCSS, RainbowKit + wagmi for wallet connection on
 Sepolia. Includes a marketplace, merchant dashboard, visual workflow builder (drag-and-drop nodes + AI
 generation), and an interactive demo terminal.

 Backend: Express 5 + TypeScript, Prisma ORM with PostgreSQL. Handles SIWE authentication, x402 gateway logic
 (402 challenges, escrow verification, content delivery), AI dispute analysis, and CRE webhook endpoints. Also
 wraps the Chainlink Private Token API with EIP-712 signed requests for shielded address generation, private
 transfers, and balance queries.

 Smart Contracts: Solidity with Foundry on Sepolia. EscrowMarketplace.sol manages the escrow state machine
 (Created → Funded → SettlementRequested/Disputed → Settled/Refunded). DisputeConsumer.sol extends Chainlink's
 ReceiverTemplate (IReceiver) to accept CRE-signed reports via the Forwarder and call finalizeSettlement() or
 resolveDispute().

 CRE Workflows: Four TypeScript workflows using @chainlink/cre-sdk. Event-triggered workflows use
 EVMClient.logTrigger() to listen for on-chain events. Cron-triggered workflows use CronCapability. All workflows
  call backend APIs via ConfidentialHTTPClient, build ABI-encoded reports, sign them with runtime.report() (ECDSA
  + keccak256), and submit to DisputeConsumer via EVMClient.writeReport().

 The dispute resolver uses dual-LLM analysis — both OpenAI and Gemini analyze the same dispute independently
 through ConfidentialHTTPClient, with fallback logic when they disagree.

Links

Created by

  • Ambesh