Skip to main content

Agentic Commerce

x402 lets any service charge for access over plain HTTP, and lets agents pay without accounts or API keys. See how you can build internet-native payments on Cardano.

What is x402?

x402 gives any website or API a built-in way to charge for a request. The web reserved a status code for this in the 1990s, 402 Payment Required, and x402 is the open standard that puts it to use. A server answers a request with a price. The client pays on chain and retries with proof of payment, and the server checks the proof and serves the resource.

The standard is governed by the x402 Foundation under the Linux Foundation. Cardano support is part of the core specification, published on npm as @x402/cardano.

Cardano and x402: npm install @x402/cardano

Why Cardano

Cardano transactions are deterministic. What a payment will do and what it will cost are known before it is signed.

Payments in parallel

An agent's payment spends its own funds, held as discrete on-chain objects in Cardano's eUTxO accounting model. Payments share nothing, so they do not wait on each other. A thousand agents can pay the same API at once.

Native stablecoins

Stablecoins on Cardano are native assets and move under the same ledger rules as ADA. An agent paying in USDM makes a normal transfer, with no token smart contract in the path and no allowance to manage.

Deterministic transactions

A Cardano transaction states its full effect in its own body, down to the exact fee. Nothing is decided after signing, which is what lets an agent commit funds on its own. It lands exactly as written or is rejected outright.

Non-custodial facilitators

Because the wallet signs the whole transaction, there is nothing left for the facilitator to change and no signature of its own to add. It holds no keys and no funds, and it can only verify and relay. It is lightweight, and anyone can easily run a facilitator themselves.

x402 goes further on Cardano

Cardano's x402 scheme defines three transfer methods: the address payment, the Masumi escrow to extend what paying agents can do, or any custom smart contract the seller declares.

x402+Masumi

Masumi is a protocol for agentic commerce on Cardano. Its escrow is native to the x402 scheme.

Standard x402x402 on Cardano
Address paymentsA direct payment to a wallet address, the baseline every chain supports.
RefundsIf nothing is delivered, the escrowed payment goes back to the client automatically.·
Decision loggingPayment decisions are recorded on-chain, decentralized and auditable.·
DiscoveryA public registry of agents, searchable through an API.·
IdentityEvery agent gets a decentralized ID and a reputation score.·

A Masumi payment goes into escrow against signed job terms, every decision is logged on chain, and the payment comes back if nothing is delivered. All of it happens inside the same x402 request.

A paid route is a dozen lines

Register the Cardano scheme, declare a price.

The middleware, the client that pays and retries, and a local facilitator are already wired in the Express template. The full reference, including the Cardano setup, is in the official x402 docs.

seller.ts
resourceServer.register("cardano:*", new ExactCardanoScheme()); // One paid route "GET /api/message": { accepts: [{ scheme: "exact", network: "cardano:mainnet", price: { amount: "100000", // 0.10 USDM asset: USDM_MAINNET_ASSET }, payTo: SELLER_ADDRESS, }], }, // The template wires the rest.
SDKCardano package on npm
$npm install @x402/cardano

Pick your starting point

Two templates to build from and one complete reference. Start from Express for a headless agent behind an API, from Next.js when a person pays in the browser.

Express starter

Client, server and a local facilitator, ready to run in two terminals.

View the template

Next.js paywall

Payment-gated routes behind a CIP-30 browser wallet paywall.

View the template

The complete demo

A working app that runs the whole x402 flow and shows each step as a payment happens. All three transfer methods, browser wallets, USDM and Masumi escrow.

Open the repository

The hosted facilitator URL and the support channel will be published here.

Go deeper: the exact scheme spec

Your agent already knows how

Two skills: current Cardano knowledge, and the Masumi context on top.

Cardano

Cardano Dev Skills

Skills and docs for the whole Cardano toolchain, refreshed weekly, so your agent builds from current facts.

Masumi

Masumi Skills

Masumi references for payments, registry and identity, so the same coding agent can build the agent layer.

Keep building on Cardano

Guides, tutorials, and templates for everything else.