TorrentSwap
Developers

x402 Explained: How AI Agents Pay With Crypto

What the x402 payment standard is, how an HTTP 402 payment flows between client, server and facilitator, which chains and stablecoins it uses, how it relates to MCP, and where it fits next to crypto swaps.

By TorrentSwap Editorial Team6 min read

x402 is an open payment standard that revives the HTTP 402 "Payment Required" status code so a website or API can charge per request. Coinbase introduced it in May 2025. A server answers 402 with its price, the client retries with a signed stablecoin payment, and a facilitator verifies and settles it onchain, with no account or API key.

Because software can complete that loop on its own, x402 has become one of the main ways AI agents pay for things. This guide explains how an x402 payment flows, which chains and stablecoins it uses, how it relates to MCP tools, where it fits and where it does not (paying for an API call is not the same as paying for a cross-chain swap), and how far adoption has come as of October 2026.

Where x402 came from

HTTP has reserved status code 402 for "payment required" since the early web, but it was never given a standard meaning, so in practice sites fell back to accounts, subscriptions and API keys. Those work for people with credit cards; they are awkward for software that needs to buy one page, one data point or one tool call at a time.

DateMilestone
May 6, 2025Coinbase announces x402 as an open standard for stablecoin payments over HTTP, with AWS, Anthropic, Circle and NEAR among the launch collaborators.
September 23, 2025Coinbase and Cloudflare announce plans for an x402 Foundation. Cloudflare proposes a "deferred" payment scheme and adds x402 support to its Agents SDK and MCP servers.
April 2026The x402 Foundation is announced under the Linux Foundation, and Coinbase contributes the protocol.
July 14, 2026The Linux Foundation announces the Foundation's operational launch with 40 member organizations.

Premier members named in the July 2026 announcement include Adyen, AWS, American Express, Circle, Cloudflare, Coinbase, Google, Mastercard, Shopify, the Solana Foundation, Stripe and Visa. The aim is vendor-neutral governance, so that no single company controls the standard.

How an x402 payment flows

An x402 exchange involves three roles: the client (the buyer, often an agent), the resource server (the seller's API) and a facilitator, an optional service that verifies and settles payments so the seller does not have to run blockchain infrastructure.

  1. The client requests a resource, such as GET /report.
  2. The server replies with status 402 and a PAYMENT-REQUIRED header listing the price, the payee and the payment options it accepts.
  3. The client signs a payment that matches one of those options and retries the request with a PAYMENT-SIGNATURE header.
  4. The server asks the facilitator to verify the payment.
  5. If valid, the server does the work.
  6. The server asks the facilitator to settle the payment onchain.
  7. The server returns the resource with a PAYMENT-RESPONSE header confirming settlement.

The whole loop happens inside ordinary HTTP requests. There is no checkout page, card form or sign-up. The protocol's stated principles also say payment schemes must not allow the facilitator or the resource server to move funds beyond what the client authorised.

Stripped down, the exchange looks like this on the wire:

GET /report HTTP/1.1
Host: api.example.com

HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: <price, payee, accepted networks and assets>

GET /report HTTP/1.1
Host: api.example.com
PAYMENT-SIGNATURE: <signed payment payload>

HTTP/1.1 200 OK
PAYMENT-RESPONSE: <Base64-encoded settlement result>

For an agent, the important part is step three. The agent needs a wallet, or access to a signer, that can authorise a payment in the asset and on the network the server asked for. Everything else is standard HTTP, which is why sellers can put x402 in front of an existing route using the published seller SDKs.

Payment schemes

SchemeHow it chargesTypical use
exactA fixed amount per requestPay-per-call APIs, paywalled pages
uptoThe client authorises a maximum; the seller settles actual usage up to that capMetered work such as model inference
batch-settlement (EVM)Escrow plus off-chain vouchers, redeemed in batchesMany tiny charges where per-payment settlement would be wasteful

Cloudflare's proposed deferred scheme goes further, separating authorisation from settlement so charges can be batched daily or settled through traditional rails.

Which chains and stablecoins x402 uses

x402 is designed to be network-agnostic: the seller chooses the chain, asset and price. In practice USDC is the most common asset. Coinbase's facilitator documentation lists support on Base, Polygon, Arbitrum, Monad, World and Solana (plus test networks), accepting ERC-20 tokens on its EVM networks through EIP-3009 or Permit2, and SPL tokens on Solana. The open-source SDKs also include packages for several other ecosystems.

Facilitators can charge for their work. As of October 2026, Coinbase's facilitator lists the first 1,000 onchain transactions each month as free and $0.001 per transaction after that, with verification always free. Other facilitators set their own terms.

x402 vs MCP tools

The two are often mentioned together, but they solve different problems.

MCPx402
Question it answersHow does an agent discover and call a tool?How does a request get paid for?
LayerAgent-to-tool protocolPayment handshake on top of HTTP
Introduced byAnthropic, November 2024Coinbase, May 2025
Who moves moneyNobody, unless a tool doesThe client's wallet signs a payment

They combine naturally. Cloudflare's Agents SDK lets an MCP server mark individual tools as paid: when an agent calls one, the server returns 402, the agent's x402 client presents the payment, and either the human or the agent can approve it before it is sent. The x402 project also publishes an MCP package for the same pattern.

Paying for APIs vs paying for swaps

x402 is built for small, priced-up-front payments for a resource: a few cents for a search, a dataset or an inference call. A cross-chain crypto swap is a different kind of transaction, and it helps to see why.

Paying for an API call with x402Executing a cross-chain swap
AmountUsually centsOften hundreds or thousands of dollars
PriceFixed by the sellerMoves with the market; quotes expire
What the client getsAn HTTP responseA different asset on a different chain
Failure handlingRetry the requestNeeds a minimum output and a refund address
Asset paidA stablecoin the seller acceptsWhatever the user is selling: BTC, ETH, SOL, USDT and others

That is why swap services for agents generally use a quote-then-deposit model instead. With TorrentSwap's MCP server and REST API, the quote and status calls are free and need no key. The agent requests a quote, confirms addresses with the user, and creates a one-time deposit address; the user then sends the funds from their own wallet. Every fee is already included in the quoted output, routes come from NEAR Intents, Chainflip and Flashnet, and TorrentSwap never holds funds. Our walkthrough on how to let an AI agent swap crypto shows the full setup.

The two models can coexist: an agent might pay for a market-data API with x402, then use a swap MCP tool to rebalance into the stablecoin it needs for future x402 payments.

Adoption as of October 2026

Coinbase's x402 documentation states that its facilitator has processed more than 100 million x402 payments across Base and Solana. Beyond volume, the clearest signal is who has signed up to govern the standard: card networks, payment processors, cloud providers and several blockchain foundations now sit together in the x402 Foundation. Cloudflare has also linked the protocol to its pay-per-crawl private beta, in which crawlers pay site owners for access.

Treat headline numbers with care, though. Many x402 payments are very small, and transaction counts say little about economic value. The standard is still young, and schemes like deferred and batch settlement are evolving.

Practical cautions for agent builders

  • Cap spending. Give an agent a dedicated wallet with a limited balance, not your main holdings.
  • Keep humans in the loop for large or unusual payments. Approval prompts exist for a reason.
  • Choose facilitators deliberately. The x402 project advises picking a production facilitator explicitly rather than assuming a default.
  • Expect no chargebacks. Onchain stablecoin payments settle; there is no card-style dispute process.
  • Watch for prompt injection. A malicious page or tool output could try to trigger payments. Restrict which hosts an agent may pay.

Build with agents that pay and swap

If your agent needs to move value across chains, not just pay for API calls, connect it to the TorrentSwap MCP server or REST API. Setup snippets, tool references and the OpenAPI spec are on the developer page.

Sources

  1. Welcome to x402 (Coinbase Developer Documentation)
  2. How x402 works (Coinbase Developer Documentation)
  3. CDP Facilitator: networks and pricing (Coinbase Developer Documentation)
  4. x402 Foundation (Coinbase Developer Documentation)
  5. x402 repository and specification (GitHub)
  6. Introducing x402: a new standard for internet-native payments (Coinbase)
  7. Coinbase x402 payments protocol to make AI agents more autonomous (Cointelegraph)
  8. Launching the x402 Foundation with Coinbase, and support for x402 transactions (Cloudflare Blog)
  9. Cloudflare and Coinbase Will Launch x402 Foundation (Cloudflare press release)
  10. Linux Foundation announces operational launch of x402 Foundation (x402.org)
  11. Introducing the Model Context Protocol (Anthropic)

Facts were checked against these sources on October 22, 2026. See our editorial policy.

Swap across chains without an account

Compare live routes from NEAR Intents, THORChain, Chainflip, Flashnet and Pact Swap. All fees already in the quote.