Prerequisites
- A wallet with ETH on Base Sepolia for gas (faucet)
- Node.js 18+ and npm
- Operator and escrow addresses from the Merchant Setup
The AI garbage detector example implements this pattern end-to-end with heuristic plus LLM evaluation.
Create the arbiter client
The role-narrowed
createArbiterClient exposes payment.voidPayment, payment.getState, and payment.getAmounts. Capturing requires the full surface, so use createX402r() directly:Handle the verify endpoint
The merchant’s
forwardToArbiter() hook POSTs { responseBody, transaction, paymentInfoWire } to /verify. The paymentInfoWire is the JSON-safe wire form of PaymentInfo; call PaymentInfo.fromWire(...) to recover the bigint-typed struct expected by SDK actions.Implement your evaluation logic
The
evaluate() function is where your logic lives. It can run:- Heuristic checks: HTTP status code, response size, content-type validation
- AI judgment: send response body to an LLM and ask “is this a valid response?”
- Schema validation: check if the response matches an expected JSON schema
Next Steps
Merchant Setup
Deploy the operator and configure forwardToArbiter().
Examples
Runnable examples for every SDK operation.
