What is x402? | Payment Protocol for AI Agents on XDC

Learn how x402 enables AI agents to make internet-native payments using the HTTP 402 status code — and why XDC Network's gasless USDC settlement and near-instant finality make it a natural home for the agent economy.

An Intro to x402

x402 is an open, internet-native payment protocol built around HTTP status code 402 — "Payment Required" — a code reserved in the web's original design but never activated. Incubated by the Coinbase Development Platform team and now maintained as an open standard, x402 lets any API or web service require payment before serving a response. No accounts, no API keys, no subscriptions, no invoices. A client requests a resource, the server replies with a price, the client attaches a signed stablecoin payment to the retried request, and the content is delivered — all within the normal HTTP flow.

For the first time, payments become a native primitive of the web itself. Learn more about the standard at x402.org.

Why XDC Network for x402?

When agents transact thousands of times per hour, the settlement rails decide whether the economics work. XDC Network is built for exactly this profile:

  • Gasless settlement for payers. With x402 on XDC, agents pay in USDC without holding XDC for gas. Meta-transaction settlement removes the biggest onboarding friction in machine-to-machine payments — no faucets, no gas top-ups, no stranded agents.
  • Near-instant deterministic finality. XDC 2.0's Proof of Stake consensus delivers transaction finality in seconds — final means final, with no reorg risk. An agent knows its payment settled before the next API call fires.
  • Fees measured in fractions of a cent. Micropayments only work when the fee doesn't eat the payment. XDC's ultra-low transaction costs make true pay-per-request pricing viable, even for calls priced at a fraction of a cent.
  • EVM-compatible, enterprise-grade. x402 servers and clients built for EVM chains work on XDC with minimal changes, and the network's decade-long track record in trade finance and real-world assets gives enterprises a compliant, production-proven settlement layer.

Powering the Agent Economy

AI agents are no longer just generating text. With modern tool use and context protocols, agents research, execute, and transact with minimal human supervision. They will pay for data feeds, fund their own compute, subscribe to services, and settle with other agents — continuously and autonomously.

This is the rise of agentic payments: a layer of the internet economy where machine-to-machine transactions represent a growing share of demand for digital services. Traditional payment rails — card networks, invoicing, subscription billing — were built for humans at human speed. They cannot underwrite an agent making a $0.001 payment every 400 milliseconds.

x402 on XDC gives that economy working rails: gasless USDC settlement, deterministic finality, and predictable sub-cent costs, on infrastructure already trusted for institutional finance.

A Growing Ecosystem

The x402 standard is blockchain-agnostic and backed by a growing community of SDK builders, payment facilitators, and platform integrations. On XDC, builders are shipping x402-enabled API servers, AI payment agents, and developer tooling that make monetizing any endpoint as simple as adding a middleware. Because x402 rides on plain HTTP, it composes cleanly with MCP servers, agent frameworks, and existing web infrastructure — no protocol lock-in, no proprietary rails.

Built Into the Internet

x402 on XDC is built into existing HTTP requests, with no additional communication required. There's no new protocol to adopt, no separate payment channel to open, no webhook to configure — the 402 status code and the payment header ride inside the same request/response cycle every API already speaks.

That means any HTTP client, server, or agent framework can add x402 support without re-architecting how it talks to the network. A request goes out, a 402 comes back if payment is due, a signed USDC payment gets attached on retry, and XDC settles it — all inside the HTTP calls that were already happening.

Accept Payments With a Single Line of Code

Getting paid for an API on XDC takes one line of middleware:

JavaScript
  1. app.use(paymentMiddleware({
  2. "GET /weather": {
  3. accepts: ["USDC"],// Stablecoin on XDC Network
  4. price: "$0.001",// Price per request
  5. network: "xdc",// Gasless settlement
  6. },
  7. }));

That's it. Add one line of code to require payment for each incoming request. If a request arrives without payment, the server responds with HTTP 402, prompting the client to pay and retry — settled on XDC in seconds, for a fraction of a cent.

Paying is just as simple on the client side:

JavaScript
  1. const client = withPaymentInterceptor(axios.create(), account);
  2.  
  3. const response = await client.get("https://api.example.com/weather");
  4. // Payment is detected, signed, and retried automatically

How do I integrate x402?

Read the Quickstart for Sellers

How to Use x402 on XDC

x402 works the same way whether you're serving an API or building the agent that calls it.

Here's how different builders get started:

If you run an API or service
You want to get paid
  1. Add an x402 payment middleware in front of your endpoint (available for common frameworks — Express, Next.js, FastAPI, and more).
  2. Set your price per request in USDC — no billing account, no Stripe integration, no invoicing required.
  3. When a client calls your endpoint without payment, your server automatically responds with HTTP 402 and the price.
  4. The client retries with a signed USDC payment attached; your server verifies and settles it on XDC, then returns the response — typically in one round trip.
If you're building an AI agent
You want to pay for things
  1. Give your agent a non-custodial wallet funded with USDC — no XDC needed for gas, since settlement is gasless.
  2. Point your agent at any x402-enabled endpoint (an XDC RPC service, a data feed, another agent's API).
  3. Your agent's client library detects the 402 response, signs the payment automatically, and retries — no manual approval step required for pay-per-call pricing under your configured limits.
  4. Set on-chain spending limits so the agent can only spend what you authorize, with every payment recorded on-chain for auditability.

If you just want to try it out:

  • Explore live x402 services and agents already running on XDC through the XDC AI marketplace (see below).
  • Use the developer quickstart docs to spin up a minimal paid endpoint or a minimal paying client in a few lines of code.

Built on XDC: XDCAI.tech

XDCAI.tech is the reference implementation of agentic commerce on XDC Network — a payment, control, and settlement framework built around the open x402 standard. It gives autonomous agents a non-custodial smart wallet and a compliant, regulated framework for paying for APIs and digital services in USDC, without subscriptions, invoices, or credit cards.

Under the hood, XDCAI combines gasless USDC payments (via EIP-3009) with user-controlled on-chain spending limits, pay-per-call API transactions, and machine-readable transaction records for every request. It supports agent-to-agent and agent-to-business payments out of the box, and integrates directly with platforms like ChatGPT, Claude, Codex, and Cursor — so an agent running in any of those environments can discover a paid service and settle payment without leaving its workflow.

XDCAI.tech is built on the same rails as native USDC and Circle's CCTP V2 on XDC Network, both already live and supporting fast, ISO 20022-compliant messaging and low-cost cross-chain transfers. It's a practical example of what "x402 on XDC" looks like in production — not a demo, but working infrastructure for a future where millions of autonomous agents transact with one another.

Real-World Use Cases

  • AI agents autonomously paying for API access, data feeds, RPC calls, and compute
  • Developers monetizing APIs per-request in USDC — no billing system, no subscriptions
  • Content and data providers charging micropayments for articles, datasets, or model inference
  • Agent-to-agent marketplaces where autonomous buyers and sellers settle 24/7
  • Trade finance and RWA platforms exposing paid data endpoints to institutional agents
Ready to build with x402 on XDC?

Need More Help?

Seeking help with setting up an XDC masternode? Access XDC documents, ask in the XDC Forum, or join Telegram's Developers community for assistance.