Skip to main content

Agentic Commerce

x402 lets any service charge per request over plain HTTP, and lets agents pay without accounts or API keys. Build internet-native payments on Cardano, with everything you need on this page.

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 has its own scheme in the x402 specification, published on npm as @x402/cardano.

Cardano and x402: npm install @x402/cardano

Why Cardano

Four properties of Cardano's ledger that matter for agentic payments.

Payments with rules

A payment can go to a smart contract instead of an address, locking the funds under rules the seller declares, such as a delivery deadline, a refund window or a release condition. Masumi's escrow is one such contract, and the ledger enforces the rules before the funds can leave it.

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

An agent sees exactly what a payment will do before it signs: the amount, the recipient and the exact fee are all in the transaction. Once signed, nothing can change it, and it lands exactly as written or not at all.

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. Anyone can run one: the template's facilitator is about 100 lines.

x402 goes further on Cardano

Cardano's x402 scheme defines three transfer methods: a payment to an address, a lock in Masumi escrow, or a lock in any smart contract the seller declares.

x402+Masumi

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

x402x402 + Masumi
Address paymentsA direct payment to a wallet address.✓✓
RefundsThe payment waits in an on-chain escrow. If nothing is delivered, the buyer requests a refund before the deadline.·✓
Decision loggingA hash of each job's input and output is stored on chain, so either side can prove what was delivered.·✓
DiscoveryAn on-chain registry of agents, searchable through an API.·✓
IdentityEvery registered agent gets an on-chain ID.·✓

A Masumi payment locks funds in escrow against job terms the seller signed. The x402 request ends at the lock. Result delivery, refunds and disputes then follow the Masumi escrow lifecycle, with every decision logged on chain.

Beyond the payment

x402 handles the payment. Masumi adds agent identity, discovery and escrow. Build on both for what agentic commerce needs next.

Spending control

Agents spend on someone's behalf. Budgets, limits and approvals enforced on chain keep a person in control.

Usage-based pricing

Credits, subscriptions and metered sessions let agents pay for what they use, beyond a single request.

Trust and reputation

Agents need to judge a service before they pay it. Reputation and proof of good work can build on Masumi's identity and on-chain history.

Privacy

Agents act for people and businesses with details to protect. Build commerce that keeps those details private.

Business operations

Agents that pay invoices, manage treasury and settle with suppliers.

New sellers

Publishers, compute providers, devices and services on other networks can sell to agents per use.

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:preprod", price: { amount: "100000", // 0.10 USDM asset: USDM_PREPROD_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. Both use TypeScript, the language of Cardano's x402 SDK.

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. Address payments and Masumi escrow, in ADA and USDM, with browser wallets.

Open the repository
Masumi

For agent services with escrow and an on-chain identity, start with Masumi. It works with CrewAI, LangGraph and other agent frameworks.

Start with Masumi
FacilitatorHosted by the Cardano Foundation, preprod
FACILITATOR_URL=https://x402.preprod.dev.ecosyseng.cf-deployments.org

Mainnet: https://x402.mainnet.dev.ecosyseng.cf-deployments.org. Every template can also run a local facilitator.

Go deeper: the exact scheme spec

Your agent already knows how

Cardano Dev Skills covers the Cardano side, Masumi Skills the agent layer. For the x402 facts in one file, give your agent agent.md.

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.