onchainexpat

Protocol

What is x402?

x402 is an open protocol that turns any API into a pay-per-request service. No API keys, no accounts, no subscriptions. Just HTTP and USDC.

How it works

1

Agent sends a request

An AI agent makes a standard HTTP POST to an x402-protected endpoint. No authentication headers needed.

POST /api/x402-crypto/token-metadata HTTP/1.1
Host: x402.onchainexpat.com
Content-Type: application/json

{"address": "0x833589fCD...", "chain": "base"}
2

Server responds with 402

The server returns HTTP 402 Payment Required with a JSON body describing the payment requirements: price, token, network, and payment address.

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "base",
    "maxAmountRequired": "20000",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0xd8bA61a0b0974db0EC8E325C7628470526558E9B"
  }]
}
3

Agent signs payment and retries

The agent signs a USDC transfer authorization (ERC-3009 transferWithAuthorization) and retries the request with the signed payment in an X-PAYMENT header.

POST /api/x402-crypto/token-metadata HTTP/1.1
Host: x402.onchainexpat.com
X-PAYMENT: eyJwYXlsb2FkIjp7InNpZ25hdHVyZSI6Ii...
Content-Type: application/json

{"address": "0x833589fCD...", "chain": "base"}
4

Server verifies and responds

A facilitator verifies the payment signature and settles the USDC transfer on-chain. The server processes the request and returns the response.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "name": "USD Coin",
  "symbol": "USDC",
  "decimals": 6,
  "security": { "verified": true, ... }
}

Why it matters

Zero signup

No accounts, no API keys, no OAuth flows. Any agent with a funded wallet can use any x402 endpoint immediately.

Micropayments

Pay fractions of a cent per request. USDC on Base L2 means near-zero gas fees, making sub-penny pricing viable.

Agent-native

Built for machine-to-machine payments. Standard HTTP headers mean any HTTP client can integrate x402 without special SDKs.

Verifiable reputation

ERC-8004 on-chain reviews let agents choose endpoints based on trust scores stored permanently on the blockchain.

Key concepts

HTTP 402

The "Payment Required" status code, part of the HTTP spec since 1999 but never standardized until x402. The protocol gives it a concrete JSON-based implementation.

Facilitator

A service that verifies ERC-3009 payment signatures and settles on-chain USDC transfers. Handles crypto verification so your endpoint doesn't have to.

X-PAYMENT

Base64-encoded JSON header containing the signed payment authorization. Included in the retry request after receiving a 402 response.

ERC-3009

The USDC transfer standard used by x402. Allows gasless, off-chain signing of transfer authorizations that the facilitator settles on-chain.

ERC-8004

An on-chain reputation standard for reviewing x402 endpoints. Scores, tags, and feedback are stored permanently on Base mainnet.

8004scan

A public registry of reviewed x402 endpoints. Browse reviewed APIs, check trust scores, and discover new services.

Get your endpoint reviewed

We test your x402 endpoint for compliance, speed, documentation, and error handling. The review is submitted on-chain via ERC-8004 and listed on 8004scan.