x402 Micropayments
Pay-per-call micropayments for AI agent tools using HTTP 402 and USDC.
x402 is an HTTP 402-based pay-per-call protocol for AI agent tools. It lets an
agent pay for tool access without creating accounts, subscriptions, or API key
programs. The payment primitive is USDC TransferWithAuthorization
(EIP-3009),
which makes each call authorizable with a signed message instead of a
pre-funded session.
In the Agent Tool Registry ecosystem, x402 is the payment layer for tools that
charge per invocation on Base with USDC. The same challenge-response flow also
works for free tools, where the signature proves caller identity but the value
is zero.
How x402 works
The protocol starts with an unauthenticated POST. The server decides whether
the request can run, and if not, returns 402 Payment Required with payment
requirements.
CALLER TOOL SERVER
| |
| 1. POST /tool (no auth) |
|-------------------------------------->|
| |
| 2. 402 + PaymentRequirements |
|<--------------------------------------|
| |
| 3. Sign TransferWithAuthorization |
| and encode X-Payment |
| |
| 4. Retry POST /tool + X-Payment |
|-------------------------------------->|
| |
| 5. Verify signature with ecrecover |
| 6. Check access predicate |
| 7. Settle onchain if needed |
| 8. Run handler and return 200 |
|<--------------------------------------|The 402 response includes a PaymentRequirements body with an accepts
array. For x402 tools, the server advertises:
{
"accepts": [
{
"scheme": "exact",
"network": "base",
"payTo": "0xOPERATOR",
"maxAmountRequired": "1000000",
"asset": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
}
]
}The caller signs the authorization from that challenge and retries with:
X-Payment: <base64(PaymentPayload)>X-Payment payload
X-Payment carries a base64-encoded PaymentPayload object:
{
"x402Version": 1,
"scheme": "exact",
"network": "base",
"payload": {
"signature": "0x...",
"authorization": {
"from": "0xCALLER",
"to": "0xOPERATOR",
"value": "1000000",
"validAfter": "0",
"validBefore": "1749158400",
"nonce": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}
}
}The server verifies the signature with ecrecover, checks that the recovered
authorization matches the challenge, and then proceeds. No RPC round trip is
needed for signature verification.
Free tools and paid tools
Free and paid tools use the same protocol. The only difference is the payment
amount.
| Tool type | maxAmountRequired | authorization.value | Result |
|---|---|---|---|
| Free tool | "0" | "0" | Zero-value signature proves identity, no funds move |
| Paid tool | Non-zero | Same non-zero amount | Signature authorizes payment and proves identity |
Free tools still use X-Payment. That keeps the access flow uniform and lets
the server recover the caller address even when no funds are transferred.
Combined predicate + payment
Some tools need both access control and payment. For those, x402 is combined
with a predicate gate such as paidPredicateGate.
- The caller makes one unauthenticated POST.
- The server returns
402with the real price inPaymentRequirements. - The caller signs once and retries with
X-Payment. - The server verifies the signature, checks the predicate, and only then
settles onchain.
If the predicate fails, the server returns 403 and no funds move. This keeps
identity, access control, and settlement in a single round trip.
Pricing in a tool manifest
Set x402 pricing in the tool manifest pricing field. See the
Tool Manifest reference for the
full schema.
{
"name": "premium-analytics",
"endpoint": "https://tools.example.com/premium-analytics",
"pricing": [
{
"protocol": "x402",
"amount": "1000000",
"asset": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"recipient": "eip155:8453:0xabcdef0123456789abcdef0123456789abcdef01"
}
]
}Use "amount": "0" for free tools that still want the x402 identity proof. In
that case, the tool server advertises the same flow but with zero-value
authorization.
Supported networks and assets
x402 on OpenSea currently supports:
- Network: Base
- Asset: USDC
The canonical asset identifier is Base USDC:
eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
Implementing x402
Use the <Anchor
label="Tool SDK"
target="_blank"
href="https://github.com/ProjectOpenSea/tool-sdk"
@opensea/tool-sdk to scaffold, deploy, register, gate, and call
tools with x402 support.
See the Agent Tool Registry
docs for the full registry flow, manifest format, and predicate examples.
