Skip to main content

What is x402?

x402 is an open payment protocol that uses the HTTP 402 Payment Required status code to enable instant stablecoin payments over HTTP. Instead of API keys or subscriptions, you pay per request with USDC. The protocol was created by Coinbase and is designed for both human users and AI agents.

The payment flow

1

Request a protected resource

Your agent sends a normal HTTP request to a paywalled endpoint (like GET /get-card?amount=50).
2

Server returns 402

The server responds with 402 Payment Required and a JSON body describing the price and how to pay.
3

Client signs a payment

Your x402 client library reads the payment requirements, constructs an EIP-3009 transferWithAuthorization payload, and signs it with your wallet’s private key. No on-chain transaction is submitted — just a signature.
4

Client retries with payment header

The client replays the original request with an X-PAYMENT header containing the signed payment.
5

Server verifies and serves

The server forwards the payment to a facilitator (Coinbase) for verification. If valid, the server returns the requested resource and the facilitator settles the USDC transfer on-chain.

The 402 response

When you hit a paywalled endpoint without paying, you get back a JSON body like this:
{
  "x402Version": 2,
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "maxAmountRequired": "5000000",
      "resource": "https://laso.finance/get-card?amount=5",
      "description": "Get Laso Finance prepaid card",
      "payTo": "0x3291e96b3bff7ed56e3ca8364273c5b4654b2b37",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    }
  ]
}
FieldDescription
schemePayment method — "exact" means pay the exact amount
networkBlockchain network in CAIP-2 format (eip155:8453 = Base mainnet)
maxAmountRequiredAmount in token base units (6 decimals for USDC, so 5000000 = $5)
payToWallet address that receives the payment
assetUSDC token contract address on Base

Key concepts

Your wallet signs, the facilitator pays gas

Your agent never submits a blockchain transaction. It only signs an authorization (EIP-3009 transferWithAuthorization). The facilitator — hosted by Coinbase — handles the on-chain settlement and pays gas fees.

Client libraries handle everything

If you use @x402/axios or @x402/fetch, the entire 402 → sign → retry flow happens automatically. Your code looks like a normal HTTP request:
import { wrapAxios } from "@x402/axios";

const client = wrapAxios(axios, wallet);
// This looks like a normal request — x402 is handled under the hood
const response = await client.get("https://laso.finance/get-card?amount=50");

Base mainnet + USDC

Laso Finance uses USDC on Base (Coinbase’s L2). Base has low gas fees and fast finality, making it ideal for microtransactions like the $0.001 /auth endpoint.

The three actors

ActorRoleExample
ClientSigns payment authorizations with a walletYour AI agent using @x402/axios
Resource serverProtects endpoints behind a paywall, verifies paymentsLaso Finance API at laso.finance
FacilitatorVerifies signatures and settles payments on-chainCoinbase’s hosted facilitator

Supported networks

x402 is chain-agnostic. The current ecosystem supports:
NetworkCAIP-2 IDToken
Base mainneteip155:8453USDC
Base Sepolia (testnet)eip155:84532USDC
Ethereum mainneteip155:1USDC
Solana mainnetsolana:mainnetUSDC
Laso Finance uses Base mainnet (eip155:8453) exclusively.

Further reading

x402 Protocol

Official x402 protocol site and whitepaper.

x402 GitHub

Open-source protocol specification and client libraries.