In 1991, the authors of what became HTTP reserved status code 402 — Payment Required — and wrote three words that would sit unused for a third of a century: “reserved for future use.” In May 2025, Coinbase and Cloudflare shipped the thing that finally used it: x402, a protocol that turns a plain 402 response into a machine-readable price quote and settles the payment in USDC on the retry. By July 2026 the x402 Foundation was operating under the Linux Foundation with 40 member organizations — Visa, Mastercard, Stripe, Google, AWS, Cloudflare and American Express among the 17 premier members (finance.yahoo.com).
This is not another crypto payment button. It fixes two constraints that have quietly shaped what software can sell for 30 years:
- Cards have a floor. Stripe’s US card rate is 2.9% + $0.30 per charge (stripe.com/pricing). That 30-cent fixed component means a $0.005 API call costs the rail 60× the price of the product. Sub-$10 software sales were structurally impossible on cards — which is why everything became $9.99/month subscriptions instead of per-call pricing.
- Cards require a human. A card means an account, a KYC’d cardholder, a session. The buyers coming online now are software — agents with wallets and no identity paperwork.
x402 removes both. This article builds the full protocol flow end-to-end in Python — real EIP-712 signatures, real wire formats, replay protection that demonstrably blocks a double-spend — and then runs the fee math that explains why card rails can’t compete below $10.31.
How the rail works
x402 V2 defines three HTTP headers (docs.x402.org):
PAYMENT-REQUIRED(server → client): Base64-encoded JSON quote — price, networks, recipient addressPAYMENT-SIGNATURE(client → server): Base64-encoded signed payment payloadPAYMENT-RESPONSE(server → client): Base64-encoded settlement receipt with the on-chain tx hash
The flow, for a GET /premium-data:
- Client GETs. Server answers
402+PAYMENT-REQUIREDwith anacceptsarray — one entry per payment route, each carryingscheme,network(CAIP-2 format, e.g.eip155:84532= Base Sepolia),amountin atomic token units,asset(token contract) andpayTo(your wallet). - Client picks a route and signs an EIP-3009
transferWithAuthorization— an EIP-712 typed-data signature over{from, to, value, validAfter, validBefore, nonce}. This is the part that matters: the client signs, it does not hand over a key. The signature authorizes exactly one USDC transfer of exactly the quoted amount, valid for a time window, to exactly the quoted recipient. - Client retries the GET with
PAYMENT-SIGNATURE. - The server verifies the payload — itself or via a facilitator (a verification/settlement service; Coinbase CDP, AsterPay, and others run production ones). Verification recovers the signer from the signature and checks amount, time window and balance.
- The facilitator broadcasts the transfer on-chain and pays the gas. On Base, that costs fractions of a cent — which is why the buyer’s payment is gasless.
- Server returns
200+ the resource +PAYMENT-RESPONSEwith the tx hash. Settlement took seconds.
No accounts. No API keys issued. No subscription. Every request is a self-contained transaction.
The lab: a machine-payable API in ~150 lines
What follows ran green (exit 0) on Python 3.14 / eth-account 0.14.0 the day this was written. What’s real: the 402 quote, the Base64 header wire format, EIP-712 typed-data signing, signature recovery, amount/time-window/nonce verification. What’s mocked: the settlement broadcast (no RPC node — the server mints a fake tx hash) and the token balance check a production facilitator runs before settling. The private key is a throwaway lab key, publicly derived, funded by nobody.
The server: quote at 402, verify on retry
# x402_lab.py — https://docs.x402.org (V2 spec), USDC on Base Sepolia
USDC_BS = "0x036CbD53842c5426634e7929541eC2318f3dCF7e" # USDC (Base Sepolia)
MERCHANT = "0x209693Bc6afc0C5328bA36FaF03C514EF312287C"
NETWORK = "eip155:84532"
PRICE = "10000" # 0.01 USDC — 6 decimals
USDC_DOMAIN = {"name": "USDC", "version": "2", "chainId": 84532,
"verifyingContract": USDC_BS}
TWA_TYPES = {"TransferWithAuthorization": [
{"name": "from", "type": "address"}, {"name": "to", "type": "address"},
{"name": "value", "type": "uint256"}, {"name": "validAfter", "type": "uint256"},
{"name": "validBefore", "type": "uint256"}, {"name": "nonce", "type": "bytes32"}]}
PAYWALL = {
"x402Version": 2, "error": "X402_PAYMENT_REQUIRED",
"resource": {"url": "http://127.0.0.1:8402/premium/satellite-passes",
"description": "Next 48h of satellite passes over Jakarta",
"mimeType": "application/json"},
"accepts": [{"scheme": "exact", "network": NETWORK, "amount": PRICE,
"asset": USDC_BS, "payTo": MERCHANT, "maxTimeoutSeconds": 60,
"extra": {"assetTransferMethod": "eip3009",
"name": "USDC", "version": "2"}}],
}
def do_GET(self):
b64 = self.headers.get("PAYMENT-SIGNATURE")
if not b64: # step 1: quote the price, sign nothing
hdr = base64.b64encode(json.dumps(PAYWALL).encode()).decode()
return self._json(402, PAYWALL, {"PAYMENT-REQUIRED": hdr})
payload = json.loads(base64.b64decode(b64))
ok, reason = self.verify(payload)
if not ok:
return self._json(402, {"error": reason},
{"PAYMENT-REQUIRED": base64.b64encode(
json.dumps(PAYWALL).encode()).decode()})
# settlement: MOCK (production: POST to facilitator /settle)
nonce = payload["payload"]["authorization"]["nonce"]
settled_nonces.add(nonce)
tx = "0x" + secrets.token_hex(32)
ledger.append({"payer": payload["payload"]["authorization"]["from"],
"amount": 0.01, "tx": tx})
settle = {"success": True, "transaction": tx, "network": NETWORK,
"payer": payload["payload"]["authorization"]["from"]}
hdr = base64.b64encode(json.dumps(settle).encode()).decode()
return self._json(200, DATA, {"PAYMENT-RESPONSE": hdr})
The verification half of a facilitator
This is where the money is protected. Five checks — signature recovery, amount match, time window, recipient match, nonce replay:
def verify(self, payload):
acc = payload.get("accepted", {})
auth = payload.get("payload", {}).get("authorization")
sig = payload.get("payload", {}).get("signature")
if not (acc and auth and sig):
return False, "invalid_payment_payload"
if acc.get("payTo") != MERCHANT or acc.get("amount") != PRICE:
return False, "invalid_exact_evm_payload_amount_mismatch"
now = time.time()
if float(auth["validBefore"]) < now:
return False, "invalid_exact_evm_payload_authorization_expired"
if float(auth["validAfter"]) > now:
return False, "invalid_exact_evm_payload_authorization_valid_after"
if auth["nonce"] in settled_nonces:
return False, "invalid_nonce_replay"
try:
td = encode_typed_data(domain_data=USDC_DOMAIN,
message_types=TWA_TYPES,
message_data={
"from": auth["from"], "to": auth["to"],
"value": int(auth["value"]),
"validAfter": int(auth["validAfter"]),
"validBefore": int(auth["validBefore"]),
"nonce": auth["nonce"]})
payer = Account.recover_message(td, signature=sig)
except Exception:
return False, "invalid_exact_evm_payload_signature"
if payer.lower() != auth["from"].lower() or auth["to"] != MERCHANT:
return False, "invalid_exact_evm_payload_signature"
return True, ""
(The error strings are the spec’s own — the V2 spec enumerates exactly these invalid_exact_evm_payload_* reasons, so your logs speak the same language as every facilitator.)
The client: an agent with a wallet
def fetch_with_wallet(url):
status, headers, body = get(url)
if status != 402:
return status, body
quote = json.loads(base64.b64decode(headers["PAYMENT-REQUIRED"]))
req = quote["accepts"][0] # pick the USDC/Base route
now = int(time.time())
auth = {"from": CLIENT.address, "to": req["payTo"],
"value": int(req["amount"]),
"validAfter": now - 10,
"validBefore": now + req["maxTimeoutSeconds"],
"nonce": "0x" + secrets.token_hex(32)}
td = encode_typed_data(domain_data=USDC_DOMAIN, message_types=TWA_TYPES,
message_data=auth)
sig = CLIENT.sign_message(td).signature.hex()
payment = {"x402Version": 2, "resource": quote["resource"],
"accepted": req,
"payload": {"signature": sig, "authorization": {
k: str(v) if k in ("validAfter", "validBefore") else v
for k, v in auth.items()}}}
hdr = base64.b64encode(json.dumps(payment).encode()).decode()
status, headers, body = get(url, {"PAYMENT-SIGNATURE": hdr})
settlement = json.loads(base64.b64decode(headers["PAYMENT-RESPONSE"]))
return status, body, settlement
Running it
$ python x402_lab.py
client wallet : 0x19E7E376E7C213B7E7e7e46cc70A5dD086DAff2A
pass 1 (no pay) -> HTTP 402 (expect 402), price: 0.01 USDC to 0x209693Bc...
pass 2 (signed) -> HTTP 200 (expect 200)
data : {"passes": [{"sat": "ISS (ZARYA)", "aos": "2026-11-11T23:41Z", ...
settlement : success=True tx=0xc6d5c3e19f121ece... payer=0x19E7E376...
merchant ledger entries: 1
pass 3 (replay) -> HTTP 402 (expect 402)
OK: 402 quote -> EIP-712 sign -> verify -> settle -> replay blocked
Pass 3 is the one that pays for itself: resubmitting a payload whose nonce already settled bounces with invalid_nonce_replay. Without that check, a replayed signature buys unlimited resources for one payment — a failure mode the spec explicitly calls out (along with a nastier Solana variant where duplicate /settle submissions both return success; servers settling SVM payments themselves must cache in-flight payloads for ~120 seconds).
The economics: where cards mathematically cannot follow
# x402_economics.py — exact decimal arithmetic, all assertions pass
STRIPE_PCT, STRIPE_FIXED = D("0.029"), D("0.30")
CDP_FEE, CDP_FREE_TIER = D("0.001"), 1000 # Coinbase CDP facilitator
p = D("0.005"); tx = 100_000 # $0.005/call API, 100k calls/mo
gross = p * tx # $500.00
card_fee = (p * STRIPE_PCT + STRIPE_FIXED) * tx
x402_fee = D(tx - CDP_FREE_TIER) * CDP_FEE # 99,000 billable settlements
Output:
== 1. Card rail floor: the 30-cent fixed fee decides what you may sell
$ 0.01 item -> Stripe fee $0.3003 (3002.9% of price)
$ 0.10 item -> Stripe fee $0.3029 ( 302.9% of price)
$ 1.00 item -> Stripe fee $0.3290 ( 32.9% of price)
== 2. Break-even: Stripe's percentage alone crosses $0.001 at
price* = (0.30 - 0.001) / 0.029 = $10.31
== 3. Worked example: $0.005/call API, 100,000 calls/month
gross revenue : $500.00
via cards, revenue left: $-29514.50 (fee $30014.50)
via x402 , revenue left: $401.00 (facilitator $99.00)
delta : $29915.50/month on a $500 product
Read that carefully, because it’s the whole business case in four numbers. There is no price at which cards win on fees. Below $10.31, the 30-cent fixed fee dominates (at a penny, cards charge 30× the product). Above $10.31, Stripe’s 2.9% percentage component alone already exceeds what an x402 facilitator charges for the entire settlement — and cards still owe the 30 cents on top. The facilitator market is priced accordingly: Coinbase CDP gives the first 1,000 settlements/month free, then $0.001 each, gas included, from January 1, 2026 (KuCoin News); AsterPay starts at ~€0.001/call; Dexter runs 0.1–0.5% (asterpay.io comparison, Jul 2026). One-tenth of a cent per settled transaction, all-in.
Now stack what it replaces. A card-based per-call product needs Stripe itself, a hosted checkout page, a subscription or prepaid-credits ledger, a webhook handler that survives deploys, dunning for failed cards, and a support inbox full of “why was I charged $9.99” — call it a weekend of engineering plus a permanent maintenance surface, each piece a chance to silently lose a sale. x402 collapses that stack into one middleware line: the 402 quote is the checkout, the signature is the auth, the settlement header is the receipt, and the facilitator’s settlement list is the ledger. No card data ever touches your servers, so PCI scope is zero. And the rail unlocks products that simply had no business model before: a $0.02 answer to “how many satellites pass over Jakarta tonight” cannot carry a $9.99 subscription and cannot survive a 30-cent rail, but at a facilitator’s tenth of a cent it keeps 98% margin per query. The same math covers pay-per-scrape, per-model-token reselling, and per-file OCR — the long tail of software that was priced out of its own rails.
The buyer’s side is equally clean: the agent pays the quoted price and zero gas (the facilitator covers it), with no account creation latency. In Q3 2026 the median new wallet made its first x402 payment 18 minutes after funding — down from 73 days in late 2025 (Fireblocks, Nov 2026).
The honest numbers on adoption
Every payments protocol inflates its launch metrics, and x402 is no exception. Here is what the data actually shows as of early November 2026:
- 196 million lifetime transactions, $42M+ settled across 12 chains as of November 1, 2026 — about 45% on Base, 34% on Solana, and over 99% of recent Base value in USDC (Fireblocks/Allium data).
- More than half of that volume was a two-month farm. Late 2025: the PING token was minted through x402 for a 1-USDC invoice, speculators ran the loop at industrial scale, transactions spiked 10,000% in a week, and November 2025 hit a record $20.5M across 52.6M transactions (≈39¢ each). When the trade died, December’s settled value halved to $9.4M while transaction count hit an all-time high of 54.2M — bots don’t care that they’re spinning dust when Base fees are fractions of a cent.
- The production floor is real, and it’s 4–6 million transactions/month since the speculation washed out — down 92% from the peak, but stable, and made of wallets that behave like subscribers: 89% of wallets first funded in Q2 2026 topped up again within 30 days.
- The payment sizes tell you what this rail is for: 87%+ of x402 payments over the last 16 months were worth between a hundredth of a cent and ten cents; Allium’s Q3 2026 agent-payment classification averaged $0.054 per payment across 68.3M payments.
So: the hype peak is behind us, the floor is real, and the floor is made of exactly the traffic that could never exist on cards — per-call machine purchases averaging a nickel.
Where this breaks
No honest write-up skips the failure modes:
- No chargebacks. Blockchain settlement is instant and irreversible. An agent that pays $0.40 and gets a half-delivered response has no recourse after the fact. The mitigations happen before payment: the time-boxed authorization (
validBefore), server-sidesettlement_pendingreconciliation (a broadcast-but-unconfirmed tx returns a non-terminal error with the tx hash — you reconcile on-chain, you don’t pay again), and the spec’s rule that a timeout afterPAYMENT-SIGNATUREwas sent is an unknown state, never a license to pay twice. - Key management becomes your attack surface. An agent holding a funded wallet key is a walking honeypot. Production designs rotate per-agent keys with spending caps, and the protocol has a scheme for it:
uptoauthorizes a maximum and the server charges actual usage, rather than signing per-request. - Facilitator dependency is optional but real. You can verify signatures locally and settle yourself (the lab does verification locally), but then you’re running RPC infrastructure, balance checks, and nonce stores — the facilitator is usually worth the tenth of a cent.
- Compliance doesn’t disappear. USDC income is still income. Screening who pays you is your problem; crypto-native facilitators generally don’t screen agents (AsterPay’s EU rail is the counter-example, at 0.5% + €0.10 all-in).
Where the money actually is
The x402 Bazaar is a machine-readable discovery layer: endpoints that answer 402 get indexed, so an agent can find paid resources the same way it crawls free ones. That flips API distribution: instead of negotiating enterprise access to your data product, you price it per call, put it behind a 402, and every agent with a wallet becomes a customer with zero onboarding. The strategy pieces worth building now: a per-call data endpoint you’d otherwise never monetize (satellite passes, court filings, price history — the long tail that can’t support a $99 tier), agent-to-agent services where your scraper bills other people’s agents by the request, and putting existing client endpoints behind 402 as an alternative to API-key provisioning. The full lab script from this article — client, server, harness, replay tests — is ~150 lines, and the production delta is a real facilitator URL and one middleware import.
Two operational details decide whether the deployment survives its first month. First, quote precision: the client signs exactly the amount in the 402 quote, so a server that recomputes prices between the quote and the retry will strand every paying agent with an amount_mismatch — treat the quote as a short-lived offer, immutable until maxTimeoutSeconds expires. Second, the agent’s loop never assumes death: on a lost response after PAYMENT-SIGNATURE, the spec’s own guidance is to reconcile the settlement (decode PAYMENT-RESPONSE, check the tx hash on-chain) rather than fire a second payment — the lab’s nonce store enforces the same invariant from the other side.
HTTP 402 waited 34 years for the two things it needed: buyers without hands, and a rail that doesn’t cost 30 cents to say “yes.” Both exist now, and the fee math says the door is open for exactly the products cards were never able to carry.
Butuh versi custom — machine-payable endpoint buat data lu, atau agent yang belanja data otomatis dengan budget cap? Email [email protected] (sama seperti di /pages/hire-us), Solvinc bangun dan integrasikan.