x402 Payments
x402 lets an agent pay for a resource over HTTP, using the402 Payment Required status code as
a protocol rather than an error. No checkout page, no human, no session.
Intents are signed off-chain, sequenced by the sequencer,
batched, and settled on Set L2.
The flow
Wire format
Base64 is used because raw JSON isn’t safe in an HTTP header value. The decoded document is exactly
what
POST /api/v1/x402/payments accepts — snake_case fields — so the header path and the API
path take the identical shape.Signing
The signature is Ed25519 over aX402_PAYMENT_V1 domain-separated SHA-256 signing hash.
The intent carries identity (intent_id, x402_version, tenant_id, store_id,
source_agent_id, the signing key id), the payment terms, and a validity window.
Protocol limits
Replay protection
A verified intent burns its nonce through a primary-key reservation in the nonce-tracking table. Submitting the same intent twice fails on the second attempt rather than paying twice — which is what makes it safe for an agent to retry a request whose response it never saw. Header-submitted intents go through the same code path as the submission endpoint, so they get a sequence number, burn their nonce, and enter the normal batching pipeline identically.Receipts
TheX-Payment-Receipt header acknowledges sequencing and points at the full Merkle receipt:
Two implementations
Try it
cli/src/x402/ — client, resource server, facilitator, budget, and
agent integration.
There’s also an x402 MCP server (stateset-x402, 5 tools) for paid API calls from
an agent.
Related
- Sequencer x402
- Set L2 — where settlement lands
- Set L2 Verification — verifying payment inclusion