A payments protocol for the internet. Built on HTTP.
x402 is a widely-adopted TypeScript project in the AI payments / x402 ecosystem. It currently has 6,373 GitHub stars and 147 forks.
This is the reference implementation of the x402 protocol — the repo that defined the standard most of this directory builds on. Maintained by Coinbase, it packages the HTTP 402 "Payment Required" handshake into production middleware and client libraries, with USDC settlement on Base and other EVM chains plus Solana support.
If you are evaluating x402 for the first time, start here rather than with a third-party SDK: the spec, the examples and the reference facilitator all live in this repository, so what you read is what the ecosystem actually implements. The TypeScript tooling is the most complete; other languages are covered by community SDKs that track this repo.
Best for: any team adding pay-per-request monetization to an API or MCP server. Pair it with a hosted facilitator if you do not want to operate settlement yourself — see the projects in our facilitators category.
Note: We've moved the x402 repo under the x402 Foundation repo. All issues and PRs were transferred here: github.com/x402-foundation/x402
Our repo (coinbase/x402) is now a development fork.
x402 is an open standard for internet native payments. It aims to support all networks (both crypto & fiat) and forms of value (stablecoins, tokens, fiat).
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [...], // As many networks / schemes as you want to support
description: "Weather data", // what your endpoint does
},
},
),
);
// That's it! See examples/ for full details
See all the packages available in the Typescript SDK, including chain implementations of x402, code examples and integration guides.
# All available reference sdks
npm install @x402/core \
@x402/evm @x402/svm @x402/stellar @x402/svm \
@x402/axios @x402/fastify @x402/fetch @x402/express @x402/hono @x402/next @x402/paywall @x402/extensions
# Minimal Fetch client
npm install @x402/core @x402/evm @x402/svm @x402/fetch
# Minimal express Server
npm install @x402/core @x402/evm @x402/svm @x402/express
See the
go/folder for code examples and integration guides.
go get github.com/x402-foundation/x402/go
The x402 ecosystem is growing! Check out our ecosystem page to see projects building with x402, including:
Want to add your project to the ecosystem? See our demo site README for detailed instructions on how to submit your project.
Roadmap: see ROADMAP.md
Documentation: see docs/ for the GitBook documentation source
resource: Something on the internet. This could be a webpage, file server, RPC service, API, any resource on the internet that accepts HTTP / HTTPS requests.client: An entity wanting to pay for a resource.facilitator: A server that facilitates verification and execution of payments for one or many networks.resource server: An HTTP server that provides an API or other resource for a client.See specs/ for full documentation of the x402 standard/
x402 payments typically adhere to the following flow, but servers have a lot of flexibility. See advanced folders in examples/.

The following outlines the flow of a payment using the x402 protocol. Note that steps (1) and (2) are optional if the client already knows the payment details accepted for a resource.
Client makes an HTTP request to a resource server.
Resource server responds with a 402 Payment Required status and a PaymentRequired b64 object return as a PAYMENT-REQUIRED header.
Client selects one of the PaymentRequirements returned by the server response and creates a PaymentPayload based on the scheme & network of the PaymentRequirements they have selected.
Client sends the HTTP request with the PAYMENT-SIGNATURE header containing the PaymentPayload to the resource server.
Resource server verifies the PaymentPayload is valid either via local verification or by POSTing the PaymentPayload and PaymentRequirements to the /verify endpoint of a facilitator.
Facilitator performs verification of the object based on the scheme and network of the PaymentPayload and returns a Verification Response.
If the Verification Response is valid, the resource server performs the work to fulfill the request. If the Verification Response is invalid, the resource server returns a 402 Payment Required status and a Payment Required Response JSON object in the response body.
Resource server either settles the payment by interacting with a blockchain directly, or by POSTing the Payment Payload and Payment PaymentRequirements to the /settle endpoint of a facilitator server.
Facilitator server submits the payment to the blockchain based on the scheme and network of the Payment Payload.
Facilitator server waits for the payment to be confirmed on the blockchain.
Facilitator server returns a Payment Execution Response to the resource server.
Resource server returns a 200 OK response to the Client with the resource they requested as the body of the HTTP response, and a PAYMENT-RESPONSE header containing the Settlement Response as Base64 encoded JSON if the payment was executed successfully.
A scheme is a logical way of moving money.
Blockchains allow for a large number of flexible ways to move money. To help facilitate an expanding number of payment use cases, the x402 protocol is extensible to different ways of settling payments via its scheme field.
Each payment scheme may have different operational functionality depending on what actions are necessary to fulfill the payment.
For example exact, the first scheme shipping as part of the protocol, would have different behavior than upto. exact transfers a specific amount (ex: pay $1 to read an article), while a theoretical upto would transfer up to an amount, based on the resources consumed during a request (ex: generating tokens from an LLM).
See specs/schemes for more details on schemes, and see specs/schemes/exact/scheme_exact_evm.md to see the first proposed scheme for exact payment on EVM chains.
Because a scheme is a logical way of moving money, the way a scheme is implemented can be different for different blockchains. (ex: the way you need to implement exact on Ethereum is very different from the way you need to implement exact on Solana).
Clients and facilitators must explicitly support different (scheme, network) pairs in order to be able to create proper payloads and verify / settle payments.
Self-healing infrastructure for AI agent payments. 90.3% auto-recovery.
Daydreams is a set of tools for building agents for commerce
The best way to monetize AI applications & MCP, using x402, CDP Smart Wallets & Paymaster
URL shortener
AWS payment demo of x402 using Bedrock AgentCore, Strands SDK, and CloudFront.
Cloudera CDP SDK for Java