All Blog Posts
Article Image

What Is x402 Protocol: A Deep Explanation of HTTP-Native Payments and the Current Landscape

13th February 2026 18min read

Your AI agent needs to call a paid API. It has a funded wallet but no credit card, no account, and no human to click "Subscribe." What payment protocol does it use?

Since 1997, HTTP 402 ("Payment Required") has been reserved in the spec, waiting for a native web payment layer that never materialized. The internet monetized through ads, subscriptions, and API keys instead. In September 2025, Coinbase and Cloudflare launched x402 to finally put 402 to work. The protocol lets services charge for API calls, digital content, and compute resources directly over HTTP, using stablecoin payments that settle in seconds without accounts, sessions, or credit card forms.

For developers building on blockchain infrastructure, x402 changes how APIs get monetized and consumed. Instead of committing to monthly subscriptions or navigating opaque compute unit systems, clients - whether human or autonomous AI agent - pay per request at the protocol level. This guide covers how x402 works, walks through a working implementation with code, and addresses the protocol's current limitations.

The HTTP 402 Backstory

When the early HTTP authors defined status codes in the 1990s, they included 402 as a placeholder. The idea was straightforward: servers should be able to tell clients "this resource costs money" and trigger a payment flow. But no payment protocol materialized.

Credit card networks were too slow and expensive for micropayments. PayPal arrived but operated outside the HTTP layer. Stripe simplified online payments but still required merchant accounts, API integrations, and 2-3% fees.

The missing ingredient was a payment rail fast enough, cheap enough, and programmable enough to work at HTTP speed. Stablecoins on low-cost blockchains - particularly USDC on Base with sub-cent transaction fees and 1-second finality - provide that rail. x402 connects it to HTTP in a standardized way.

How x402 Works

x402 operates as a challenge-response flow built on standard HTTP headers. No new transport protocols, no WebSocket connections, no custom authentication schemes. A client makes a normal HTTP request, and the server either delivers the resource or asks for payment.

The Payment Flow

Here is the complete sequence for an x402 payment.

Step 1: Client requests a protected resource.

GET /api/v1/market-data HTTP/1.1
Host: api.example.com

Step 2: Server responds with 402 and payment requirements.

HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: eyJwcmljZSI6IjEwMDAwMCIsInRva2VuIjoiVVNEQyIsImNoYWluIjoiYmFzZSIsInJlY2lwaWVudCI6IjB4Li4uIn0=

The PAYMENT-REQUIRED header contains a base64-encoded JSON payload specifying the price, accepted token, blockchain network, and recipient address. Decoded, it looks like this:

{
  "price": "100000",
  "token": "USDC",
  "chain": "base",
  "recipient": "0x1234...abcd",
  "scheme": "exact"
}

Step 3: Client signs a payment authorization.

The client reads the payment requirements, constructs an EIP-3009 TransferWithAuthorization, and signs it using EIP-712 typed structured data. This creates a gasless payment authorization. The client never submits a blockchain transaction directly.

{
  "from": "0xClientWallet...",
  "to": "0xRecipientAddress...",
  "value": "100000",
  "validAfter": "0",
  "validBefore": "1707868800",
  "nonce": "0xUniqueRandomNonce..."
}

Step 4: Client resends the request with the signed payment.

GET /api/v1/market-data HTTP/1.1
Host: api.example.com
PAYMENT-SIGNATURE: eyJzaWduYXR1cmUiOiIweC4uLiIsInBheWxvYWQiOnsidmFsdWUiOiIxMDAwMDAiLCJ0b2tlbiI6IlVTREMifX0=

Step 5: Server forwards payment to a Facilitator.

The Facilitator verifies the signature, submits the TransferWithAuthorization transaction on-chain, and confirms settlement back to the server.

Step 6: Server delivers the resource.

HTTP/1.1 200 OK
PAYMENT-RESPONSE: eyJ0eEhhc2giOiIweC4uLiIsInN0YXR1cyI6InNldHRsZWQifQ==
Content-Type: application/json

{ "data": { "BTC/USD": 97432.50, "ETH/USD": 3821.15 } }

The entire flow completes in approximately 1-2 seconds on Base, with the payment settled on-chain before the response reaches the client.

The "Exact" Payment Scheme

The current production scheme is called "exact," where a predetermined amount transfers for each request. For example, $0.01 per API call or $0.10 per article. The EIP-712 typed data structure includes domain separators (contract address and chain ID) that prevent cross-network signature reuse, and unique nonces prevent replay attacks.

Key Cryptographic Dependencies

x402 relies on two Ethereum standards working together:

  • EIP-3009 (TransferWithAuthorization): Enables gasless token transfers. The token holder signs an authorization, and a third party (the Facilitator) submits the actual transaction. The client never needs ETH for gas.
  • EIP-712 (Typed Structured Data Signing): Provides human-readable signing prompts and domain separation, preventing signature reuse across different contracts or chains.

This dependency on EIP-3009 has significant implications covered in the limitations section below.

Building with x402: A Working Implementation

The protocol theory above translates directly into working code. The x402-demo repository contains a minimal but complete implementation: an Express server that charges $0.001 USDC per API call and clients that handle the payment flow automatically. The full source code, setup instructions, and testnet configuration are available in the repository.

x402 SDK Packages

The x402 ecosystem provides modular npm packages that handle the protocol mechanics:

PackagePurpose
@x402/expressExpress middleware that intercepts requests and enforces payment
@x402/fetchClient-side fetch wrapper that auto-handles 402 responses
@x402/evmEVM-specific payment scheme (signing, verification)
@x402/coreCore protocol types and Facilitator client

Server: Adding Payment to an Express API

The server side requires two things: configuring a Facilitator client (which handles on-chain verification) and applying payment middleware to routes. Here is the core setup from the demo:

import express from "express";
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { HTTPFacilitatorClient } from "@x402/core/server";

const facilitator = new HTTPFacilitatorClient({
  url: "https://x402.org/facilitator",
});

const resourceServer = new x402ResourceServer(facilitator)
  .register("eip155:84532", new ExactEvmScheme());

const app = express();

app.use(
  paymentMiddleware(
    {
      "GET /joke": {
        accepts: [
          {
            scheme: "exact",
            price: "$0.001",
            network: "eip155:84532",
            payTo: process.env.PAY_TO_ADDRESS,
          },
        ],
        description: "A joke that costs $0.001",
        mimeType: "application/json",
      },
    },
    resourceServer,
  ),
);

// This route only executes after payment verification succeeds
app.get("/joke", (_req, res) => {
  res.json({ joke: "Why do programmers prefer dark mode? Because light attracts bugs." });
});

The paymentMiddleware function maps routes to pricing. When a request hits GET /joke without a valid payment header, the middleware returns an HTTP 402 response with the pricing details. When a valid signed USDC permit accompanies the request, the middleware verifies it through the Facilitator and passes control to the route handler. The server never touches the blockchain directly.

Client: Automated Payment with Fetch Wrapper

On the client side, the @x402/fetch package wraps the standard fetch API to handle the 402 challenge-response automatically. For headless services and AI agents, this is the key integration point:

import { privateKeyToAccount } from "viem/accounts";
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";

// Create a signer from a private key (for agents and backend services)
const account = privateKeyToAccount(process.env.PRIVATE_KEY);

// Initialize the x402 client and register the EVM payment scheme
const client = new x402Client();
registerExactEvmScheme(client, { signer: account });

// Wrap fetch to auto-handle 402 responses
const fetchWithPay = wrapFetchWithPayment(fetch, client);

// Make a paid API call - the wrapper handles the full payment flow
const response = await fetchWithPay("http://localhost:4021/joke");
const data = await response.json();
console.log(data.joke);

The wrapFetchWithPayment function intercepts 402 responses, parses the payment requirements, signs a USDC permit using the provided wallet, and retries the request with the payment header attached. From the developer's perspective, it works like a normal fetch call.

Browser Client: Wallet-Based Payments

For browser applications, the same @x402/fetch wrapper works with injected wallets like MetaMask. The key difference is how the signer is created:

import { createWalletClient, custom } from "viem";
import { baseSepolia } from "viem/chains";
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";

// Connect to the user's browser wallet
const [address] = await window.ethereum.request({
  method: "eth_requestAccounts",
});

const wallet = createWalletClient({
  account: address,
  chain: baseSepolia,
  transport: custom(window.ethereum),
});

// Bridge the wallet to the x402 signer interface
const signer = {
  address,
  signTypedData: async (params) =>
    wallet.signTypedData({
      account: address,
      domain: params.domain,
      types: params.types,
      primaryType: params.primaryType,
      message: params.message,
    }),
};

const client = new x402Client();
registerExactEvmScheme(client, { signer });
const fetchWithPay = wrapFetchWithPayment(fetch, client);

// Each call triggers a wallet signature prompt for the USDC permit
const response = await fetchWithPay("/joke");

When the user clicks "Pay $0.001 for a Joke," their wallet prompts them to sign a typed data message (the USDC permit). No ETH is required for gas since the Facilitator submits the on-chain transaction.

Running the Demo Locally

To try the full flow on Base Sepolia testnet:

git clone https://github.com/dwellir-public/x402-demo.git
cd x402-demo
npm install

# Configure your receiving wallet address
cp .env.example .env
# Edit .env: set PAY_TO_ADDRESS to any wallet you control

# Start the server (port 4021)
npm run server

# Option A: Browser client with wallet (port 5173)
npm run dev

# Option B: Headless client with private key
# Add PRIVATE_KEY to .env first
npm run client

You need testnet USDC on Base Sepolia to make payments. Get it from the Circle faucet. The demo uses eip155:84532 (Base Sepolia) by default. For production, change the network to eip155:8453 (Base mainnet) and point the Facilitator URL to the production endpoint.

V2 Protocol Updates

The x402 V2 specification, released in January 2026, addresses several shortcomings of the original design.

FeatureV1V2
Request headerX-PAYMENTPAYMENT-SIGNATURE
Response headerX-PAYMENT-RESPONSEPAYMENT-RESPONSE
Session supportNone (pay every call)Wallet-based identity, reusable sessions
Chain supportBase, EthereumMulti-chain via CAIP standards
API discoveryManualAutomatic
Payment recipientsStaticDynamic
SDK architectureMonolithicModular (custom networks and schemes)

The most impactful V2 change is session support. In V1, every API call required a full on-chain transaction, making high-frequency use cases like streaming data or rapid API queries impractical. V2 introduces wallet-based identity where a client authenticates once and makes subsequent requests without repeating the payment handshake, reducing both latency and on-chain costs.

Supported Chains

With the protocol mechanics covered, the next question is where x402 runs. It operates across multiple blockchain networks, though adoption and practicality vary by chain.

ChainStatusAvg. Transaction CostNotes
BasePrimary< $0.01Coinbase's L2. Near-zero fees make micropayments viable. Primary production chain.
EthereumSupported$1-10+Higher gas costs make micropayments impractical for small amounts.
SolanaSupported (V2)~$0.00025400ms finality. Non-EVM, uses different signing standards.
ArbitrumSupported$0.01-0.10L2 with moderate fees.
OptimismSupported$0.01-0.10OP Stack L2.
PolygonSupported< $0.01Low-cost EVM chain.
AlgorandSupported (V2)< $0.001Non-EVM, low fees.

Base dominates x402 usage. As Coinbase's own L2, it offers the tightest integration with the Coinbase Developer Platform Facilitator, sub-cent transaction costs, and 1-second block times. For developers evaluating Base RPC providers, x402 compatibility is becoming a relevant selection factor.

The Facilitator Model

The chain support table raises a question: who actually submits the on-chain transactions? That is the Facilitator's job. Without Facilitators, every server accepting x402 payments would need to implement blockchain transaction submission, signature verification, nonce management, and settlement confirmation.

A Facilitator handles:

  • Signature verification: Confirming the client's EIP-712 signature is valid
  • On-chain settlement: Submitting the TransferWithAuthorization transaction
  • Confirmation: Reporting settlement status back to the server
  • Replay protection: Tracking used nonces to prevent double-spending

Currently, the Coinbase Developer Platform (CDP) hosts the primary Facilitator, offering fee-free USDC settlement on Base mainnet. Servers receive 100% of the payment amount with no protocol fees, a clear advantage over traditional payment processors that charge 2-3%.

The centralization risk is obvious: relying on a single Facilitator controlled by Coinbase undermines the open protocol's decentralization goals. The x402 Foundation has announced work on open Facilitator implementations, but as of February 2026, CDP remains the dominant option.

Use Cases

With the protocol architecture and Facilitator model established, where does x402 apply in practice?

AI Agent Payments

This is x402's most compelling near-term use case. Autonomous AI agents need to pay for services (API calls, compute, data feeds) without human intervention. Traditional payment methods require credit cards, accounts, and manual authorization. x402 lets an agent with a funded wallet pay for any x402-enabled service programmatically.

The market trajectory supports this direction. Gartner projects 40% of enterprise applications will embed AI agents by 2026, with $15 trillion in AI agent B2B purchases expected by 2028. x402 provides the payment rail these agents need.

The complementary ERC-8004 standard adds identity and reputation infrastructure for AI agents. Where x402 handles payment, ERC-8004 lets agents discover services, evaluate providers, and build trust scores. Together, they enable autonomous API marketplaces where agents find, evaluate, and pay for services without human involvement.

Pay-Per-Request APIs

x402 eliminates the subscription-or-nothing model for API monetization. CoinGecko charges $0.01 per API call via x402, with no API key registration, no monthly commitment, and no minimum spend. A developer can make 10 requests for $0.10 and walk away.

This model benefits both infrequent API consumers who cannot justify monthly subscriptions and API providers looking to monetize long-tail usage.

Content Monetization

Publishers can charge per article ($0.05-$0.25) instead of requiring full subscriptions. The server returns a 402 response with the article price, the reader's wallet signs a payment, and the content unlocks. No paywall accounts, no cookie tracking, no email collection.

RPC and Infrastructure Billing

x402 could enable true pay-per-request billing for blockchain infrastructure. Instead of committing to monthly plans with fixed request allocations, developers and AI agents could pay per RPC call at the moment of use. This aligns with the broader industry trend toward transparent, per-request pricing models and eliminates the friction of subscription management for variable workloads.

MCP Server Integration

As of early 2026, 18 MCP (Model Context Protocol) servers support x402 integration, enabling AI assistants to pay for services during task execution. An AI assistant helping you analyze on-chain data could autonomously pay for premium API access mid-conversation.

x402 vs. Alternatives

x402 is not the first attempt at internet-native payments. Here is how it compares to existing approaches.

x402L402/LSATTraditional (Stripe)Compute Units (Alchemy, etc.)
Payment railUSDC on Base/Solana/EVMLightning Network + MacaroonsCredit cardsSubscription + metering
Protocol fees0% (CDP Facilitator)Network routing fees2-3%Included in pricing
Settlement time~1 second (Base)< 1 second1-3 business daysN/A (prepaid)
Micropayment floor~$0.001 (Base)~$0.00001~$0.50 (practical)N/A
Agent-friendlyYes (programmatic signing)Partial (channel management)No (requires accounts)Partial (API keys)
Token supportPrimarily USDCBitcoin onlyFiat currenciesN/A
MaturityEarly (launched Sep 2025)Multi-yearDecadesEstablished
Multi-chainYes (V2)Bitcoin/Lightning onlyN/AProvider-specific

x402 vs. L402/LSAT: L402 (formerly LSAT) uses Bitcoin's Lightning Network with Macaroon-based authentication. It offers sub-cent micropayments and several years of production maturity. However, it is limited to Bitcoin, requires channel management, and lacks stablecoin support, making it unsuitable for applications needing dollar-denominated pricing.

x402 vs. Traditional Payments: Stripe and similar processors offer decades of reliability and fiat currency support. But 2-3% fees make micropayments uneconomical (a $0.01 payment would cost more in fees than the payment itself), settlement takes days, and the account-based model is incompatible with autonomous agents.

x402 vs. Compute Units: Compute unit models bundle pricing into opaque subscription tiers. x402 offers per-request transparency but requires crypto wallets and stablecoin holdings, a barrier for teams not already in the Web3 ecosystem.

Adoption and Growth

The x402 ecosystem has grown rapidly since its September 2025 launch:

  • 100+ million payment flows processed since launch
  • $600+ million in total payment volume by November 2025
  • 15+ million total transactions across all x402-integrated projects
  • 1+ billion HTTP 402 responses processed daily by Cloudflare
  • 60+ contributors across ecosystems
  • 10,000% month-over-month increase in transaction volumes during Q4 2025

Key adopters include AWS, Anthropic, Google Cloud, Stripe, and Cloudflare (which co-founded the x402 Foundation). QuickNode has published implementation guides, and CoinGecko runs production x402 endpoints.

For a protocol under a year old, these figures reflect rapid early traction, though a significant portion of volume comes from Coinbase's own ecosystem and partnerships.

Limitations and Challenges

x402 has several significant challenges that developers should weigh carefully before adopting it.

EIP-3009 Token Lock-In

This is x402's most fundamental constraint. The protocol depends on EIP-3009 (TransferWithAuthorization) for gasless payments, and only USDC and EURC natively support this standard. Despite token-agnosticism claims in the V2 specification, 98.7% of x402 volume uses USDC.

USDT (Tether) has no EIP-3009 support. With $140+ billion in supply, USDT's exclusion locks out the largest stablecoin from x402's payment rail. Until EIP-3009 adoption expands or x402 implements alternative transfer mechanisms, token choice remains severely limited.

The Bootstrapping Problem

x402 faces a classic chicken-and-egg challenge. Few websites implement 402 responses because few clients support the protocol. Few clients add x402 support because few servers accept it. Breaking this cycle requires coordinated adoption, which is why Coinbase and Cloudflare's involvement matters. But the protocol is still far from ubiquitous.

Wallet Infrastructure Gaps

For x402 to reach mainstream adoption, wallets need native 402 handling: automatically detecting payment requirements, displaying costs to users, and signing authorizations. Most wallets do not support this today, and smart wallet support is particularly limited.

Facilitator Centralization

The Coinbase Developer Platform Facilitator processes the vast majority of x402 transactions. While the protocol specification is open, the practical infrastructure is centralized. Open Facilitator implementations are in development but not yet production-ready.

Relay Economics

Facilitators bear the on-chain transaction costs (gas fees) when submitting TransferWithAuthorization transactions. On Base, these costs are negligible (sub-cent). On Ethereum mainnet, they can be substantial. The protocol has no built-in mechanism to compensate Facilitators, creating sustainability questions for open Facilitator operators.

Latency Overhead

The 402 challenge-response handshake adds approximately 2 seconds of round-trip latency without optimization. For latency-sensitive applications, this overhead is significant. V2's session support mitigates it for repeated calls to the same service, but the initial handshake cost remains.

Regulatory Uncertainty

x402 processes stablecoin payments without built-in KYC or sanctions screening. The protocol's regulatory status as a payment protocol, money transmitter, or something else remains unclear in many jurisdictions. Enterprises in regulated industries may face compliance hurdles when adopting x402.

Roadmap and Projections

Beyond fixing current limitations, the x402 Foundation has outlined its 2026 roadmap:

  • Q1 2026: Multi-chain Facilitator expansion beyond Base
  • Q2 2026: Governance launch with token-based voting
  • Mid-2026: Arbitration system beta for dispute resolution
  • The Ethereum Foundation's dAI team includes x402 as a key priority

Broader market projections provide context for x402's potential. Stablecoin payment flows are projected to grow from $33 trillion in 2025 to $56 trillion by 2030, and Gartner estimates 20% of monetary transactions will be programmable by 2030. The AI agent market alone is expected to reach $80-$100 billion by 2030, up from $12-$15 billion in 2025.

Whether x402 captures a meaningful share of these flows depends on solving the bootstrapping problem, expanding token support beyond USDC, and building the wallet infrastructure needed for mainstream adoption.

What This Means for RPC Infrastructure

x402 has direct implications for how blockchain infrastructure gets consumed and monetized. If the protocol achieves broad adoption, RPC providers could offer x402-enabled endpoints where developers and AI agents pay per request at the moment of use, with no API keys, no subscriptions, and no account creation.

This model aligns naturally with transparent per-request pricing. A provider charging $0.001 per RPC call via x402 gives developers exact cost visibility and zero commitment. AI agents building multi-chain applications could programmatically select and pay for RPC services across different networks without any human setup.

Dwellir's infrastructure covers many of the chains where x402 operates, including Base, Ethereum, Solana, Arbitrum, Optimism, and Polygon among 150+ supported networks. The transparent 1:1 pricing model (1 RPC response = 1 API credit) mirrors the per-request philosophy that x402 brings to the protocol level. As x402 matures, infrastructure providers with broad multi-chain coverage and predictable per-request economics are well-positioned to integrate.

Key Takeaways

x402 fills a real gap. The web has lacked a native payment layer since its inception. x402 provides one that works at HTTP speed with near-zero fees on Layer 2 chains.

AI agents are the killer use case. Autonomous systems that need to pay for services without human intervention benefit most from x402's programmatic, account-free payment model.

USDC dependency is the biggest limitation. Until EIP-3009 support expands beyond Circle's stablecoins, x402 remains tied to USDC, excluding the $140+ billion USDT market.

The protocol is early. Strong growth metrics (100M+ payment flows, $600M+ volume) come with the caveat that most activity centers on Coinbase's ecosystem. Broad adoption requires solving the bootstrapping problem.

V2 addresses critical V1 gaps. Session support, multi-chain expansion, and modular SDKs make V2 more practical for production use cases, particularly high-frequency API consumption.

Watch the Facilitator ecosystem. The shift from CDP-only to open Facilitators will determine whether x402 achieves genuine decentralization or remains a Coinbase-adjacent payment rail.


Building on chains where x402 operates? Dwellir provides RPC endpoints across Base, Ethereum, Solana, and 150+ networks with transparent per-request pricing.

read another blog post

© Copyright 2025 Dwellir AB