Prototype for an M2M research marketplace where an Execution Agent pays an Oracle Agent for high-conviction trading signals using an x402-style payment challenge, Circle agent wallets, CCTP funding, FX conversion, and paymaster-sponsored settlement.
- Circle Wallets: each autonomous agent has a programmatic wallet identity. The demo uses deterministic mock Circle wallet records in
src/lib/state.ts; production swaps these calls for Circle Developer-Controlled Wallet APIs. - Identity and Compliance: the API Gateway checks
x-agent-idagainst a KYB/KYC registry before it will quote or settle. Non-approved agents receive403. - CCTP Funding: if the Execution Agent lacks Arc USDC, it burns mock USDC on a source testnet and mints Arc USDC before payment. Production maps this to CCTP
TokenMessengerburn, Circle attestation, then destination mint. - FX Engine: if USDC is still short, the agent converts EURC to USDC before settlement. In production, this can route through Circle Mint, Gateway liquidity, or a DEX/RFQ venue.
- API Gateway: Express sits in front of the Oracle Agent at
/oracle/signal, enforces compliance, issues x402 invoices, validates settlement proofs, and forwards authorized requests. - x402 + Agent Wallets: first request returns HTTP
402 Payment Requiredwith an invoice payload. The agent signs and settles the invoice, then retries withx-payment. - Paymaster: settlement is modeled as a gasless ERC-4337-style user operation sponsored by a paymaster. Production should replace the mock with Circle Paymaster-compatible UserOp construction and bundler submission.
- Opt-in Privacy: invoice and response include a privacy commitment and proof. With
privacy=true, the signal payload is AES-GCM encrypted for the Execution Agent.
npm install
npm run dev:gatewayIn another terminal:
npm run dev:agentExpected behavior:
- Agent calls
/oracle/signal. - Gateway returns
402with a USDC invoice. - Agent runs compliance-aware funding logic, bridges if needed, converts EURC if needed, signs a gasless payment, settles, and retries.
- Gateway returns the trading signal JSON or encrypted private payload.
CircleWalletService: Circle wallet identity and signing. SetCIRCLE_USE_REAL=trueand provide Circle wallet IDs/addresses in.env.CctpBridge: real mode creates a Circle developer-controlled transfer on the source chain and fetches CCTP Iris messages fromhttps://iris-api-sandbox.circle.com.FxEngine: real mode calls a configuredCIRCLE_STABLEFX_BASE_URLfor EURC/USDC quotes.PaymasterClient: currently prepares the sponsored UserOp envelope; plug itsuserOperationHashinto your Circle Paymaster/bundler flow.X402Facilitator: real mode callsCIRCLE_X402_FACILITATOR_URL/verify; mock mode settles against the local ledger.PrivacyService: replace hash commitment mock with TLS-notary, ZK proof, TEE attestation, or encrypted signal delivery keys.
Copy .env.example to .env, fill in your Circle sandbox/testnet values, then run with:
CIRCLE_USE_REAL=true npm run dev:gatewayThe real integration points are intentionally isolated in src/lib/circle-client.ts and src/lib/services.ts, so the hackathon demo can keep running locally while credentials and final Circle endpoint access are added.
Docs used for the integration shape:
- Circle Developer-Controlled Wallet transfer API: https://developers.circle.com/api-reference/wallets/developer-controlled-wallets/create-developer-transaction-transfer
- CCTP technical guide and Iris endpoints: https://developers.circle.com/cctp/technical-guide/
- x402 Nanopayments concept: https://developers.circle.com/gateway/nanopayments/concepts/x402
- x402 Nanopayments integration guide: https://developers.circle.com/gateway/nanopayments/howtos/x402-integration