Skip to main content
The Quickstart replays a bundled fixture. This is a real run: an agent pays two APIs, haia-trace assembles the receipts, and the agent reads its own verdict and stops spending.

Run it

Three steps — record, assemble, act:
The middle step is Trace. The other two are the agent — which is the whole point: recording and assembling are separate from the payment, and nothing in the payment path waits on them.

1. The agent pays

Two paid calls. The first settles. The second is signed, sent, and never comes back with a settlement — the agent is left holding a payment it cannot account for. It records as it goes, to a run file it owns.
Terminal recording of node buyer.mjs: the traced agent pays two APIs, the second returning no settlement, and writes the run to .trace/events.

2. haia-trace build assembles the receipts

The agent has already exited. This step reads the evidence it left behind — one Receipt per operation — and could just as well run on another machine.
Terminal recording of haia-trace build: two receipts assembled from nine events, op-1 FULL and op-2 PARTIAL with an observed fault and a missing settlement.
op-2 is the point. A signed authorization left the agent and nothing came back to say what became of it. The agent cannot tell a payment that never settled from one that settled silently — so instead of guessing either way, the receipt names the milestone that stayed open and records the fault it saw.

3. The agent acts on the verdict

completeness and missing are read by a machine, with no human in the loop. The process exits non-zero, so the same file works unchanged as a CI gate.
Terminal recording of node policy.mjs: op-1 is complete and safe to continue, op-2 is partial and stops the spend chain, exit status 1.
The money and the sellers are simulated — there is no chain, no facilitator and no wallet. Everything between the hook firing and the verdict is the shipped code path: the @x402/core client, its hooks, the recorder, the events on disk, and the assembler. This example fakes the payment, never the trace.

The same recorder in a full application

arc-nanopayments is a complete app — gasless USDC nanopayments on Arc, with an autonomous buyer agent, a Next.js seller and a dashboard. It traces both sides of the payment, and attaches to Circle’s @circle-fin/x402-batching rather than @x402/core: the same one-line attach against another SDK’s hooks.

The buyer

agent.mts — the agent attaches to its GatewayClient and records as arc-nanopayments-buyer.

The seller

lib/x402.ts — the paywalled routes attach to the gateway middleware and record as arc-nanopayments-seller.
Its dashboard reads the run files straight back off disk and renders a payment timeline — the recorded events, not assembled Receipts. The app never has to ask anyone for its own evidence. Live at arc-nanopayments.gdev.haust.app — it opens on a sign-in screen, and the account is in the repository’s Demo Credentials. A second app, arc-escrow — an end-to-end escrow workflow on Arc — is still being built and is not traced yet.

Next steps

Connect x402

The one-line attach, what gets recorded, and what never does.

What a Receipt is

Stages, evidence, missing, exceptions — the model behind the verdict.

See all three roles

The buyer’s, the seller’s and the facilitator’s view of one payment.

CLI reference

Every command, flag, and the .trace/ layout.