Features Protocol API Agent ↔ Agent Roles GitHub ↗
Free & Open Source · MIT Licensed · HTTP 402

Agents pay agents.
No gas. No wait.

x402s brings off-chain micropayments to the agentic web. Agent-to-API. Agent-to-agent. State channels replace on-chain transactions — pay with signed state, not gas.

Quick Start → How It Works
A
Agent
H
Hub
P
Payee
A1
Agent 1
H
Hub
A2
Agent 2
A
Agent
H
Hub
P
Payee
A1
Agent 1
H
Hub
A2
Agent 2
402 + offersquote → ticket
PAYMENT-SIGNATURE200 + receipt
A₁ signs statehub forwards
A₂ delivers datareceipt + proof
Free
No platform fees
0 gas
Per request
<50ms
Latency
ERC-20
Any asset

Agent payments
without the friction

Every on-chain tx costs gas, time, and complexity. State channels move payment off-chain. Settle only when you need to.

On-chain per call

  • Gas fee every request
  • Block confirmation latency
  • Chain congestion risk
  • Public spending graph

x402s State Channels

  • Zero gas per request
  • Instant signed-state payment
  • Private tx flow off-chain
  • On-chain only at open / close
  • Settle only when needed
01

Off-chain speed

Payments are signed channel state updates. No blocks to wait for. Pay and respond in one round-trip.

02

On-chain safety

Dispute contract enforces honest settlement. Challenge watcher catches stale closes. Funds always recoverable.

03

HTTP-native

APIs return 402 with offers. Agents retry with payment proof. Standard headers, no custom transport.

04

Private transactions

Payment state stays off-chain between participants. No public transaction leakage during API traffic.

05

Hub routing

One channel to a hub unlocks every connected payee. Pay many APIs from a single funded channel.

06

Multi-asset

USDC, ETH, any ERC-20. Per-path pricing in human units. Payees set offers, agents pick what they hold.

07

Agent-first

Built for autonomous agents. Auto, per-payment, or per-API approval modes. CLI + SDK + HTTP server.

08

Agent skill included

Ships a ready-made skill folder. Drop it into Claude or any LLM agent for automatic 402 handling.

09

Free & open

MIT licensed. No transaction fees, no lock-in. Run your own hub or use a public one. Fork it, ship it.

Four steps to pay

From 402 response to 200. The full payment lifecycle.

1

Discover

Agent GETs a resource. Payee returns 402 with accepted payment offers: networks, assets, prices, route modes.

2

Quote

Agent sends offer to hub. Hub calculates fee, returns a quote with a payment draft ready to sign.

3

Issue

Agent signs channel state update. Hub validates, co-signs, returns a ticket: the payment proof.

4

Pay + Verify

Agent retries with PAYMENT-SIGNATURE header. Payee verifies ticket, returns 200 + receipt.

Agents paying agents,
through the hub

Any agent can be both payer and payee. The hub routes payments between them — no direct channel required.

🔍

Research agent buys data

Agent 1 needs market data. Agent 2 has a crawl pipeline. A₁ pays A₂ per-query through the hub. No API registration — just a 402 endpoint.

🧠

Inference on demand

A coding agent hits a limit. It discovers a specialized model agent advertising inference via 402. Pay per call, get structured output back.

🔗

Multi-agent orchestration

An orchestrator fans out tasks to specialist agents. Each sub-agent bills for its work. The hub settles all flows from one channel.

Micro-bounties

An agent posts a task with a price. The first agent to return a valid result gets paid instantly — verified by the hub, no escrow contract needed.

1 Both agents open channels to the same hub
2 Agent 1 pays Agent 2 via the hub — one state update each side
3 Settle on-chain only when a channel closes

Five minutes to
first payment

Install, configure, open a channel, and pay. The wizard handles setup; you handle the API calls.

CLI SDK HTTP Server Dashboard
terminal
# setup npm install npm run scp:wizard # open a channel npm run scp:channel:open -- \ 0xHubAddr base usdc 20 # pay an API npm run scp:agent:pay -- \ https://api.example/v1/data

Protect an
endpoint

Return HTTP 402 with offers when unpaid, then verify the payment signature and serve data with a receipt.

402 accepts[] verify receipt
payee-api.js
const sig = req.headers["payment-signature"]; if (!sig) { const accepts = buildAccepts({ file: process.env.OFFERS_FILE, path: req.path, host: req.headers.host }); return res.status(402).json({ error: "payment required", accepts }); } const result = await verify(sig, store); if (result.replayed) return res.json(result.response); if (!result.ok) return res.status(402).json({ error: result.error }); const resp = { ok: true, data, receipt: { paymentId: result.paymentId } }; verify.seen.set(result.paymentId, resp); return res.json(resp);

Run what you need

Most users only need the agent. Build paid APIs or run hub infra when you're ready.

Most users

Agent (Payer)

Discover offers, open channels, pay APIs. Auto-mode handles everything; manual mode gives you control.

npm run scp:agent:pay -- <url>
API devs

Payee API

Protect routes with 402, define per-path pricing in JSON, validate tickets. Template included.

npm run scp:payee
Infra ops

Hub Operator

Quote fees, issue tickets, track settlements. Scale with Redis + cluster mode for production.

npm run scp:hub

Build paid APIs and agents.

Install, open a channel, pay. The wizard handles setup — deploy on Sepolia, Base, or any EVM chain.

$ npm run scp:wizard