x402
Pay-per-request HTTP payments settled in USDC on Base.
Alchemy's endpoint: https://x402.alchemy.com · Coinbase facilitator:
https://api.cdp.coinbase.com/platform/v2/x402
This file records our position on it, not the protocol spec.
The idea
A server responds 402 Payment Required with a PAYMENT-REQUIRED header describing
price and network. The client signs a USDC payment, retries with PAYMENT-SIGNATURE,
and gets the resource. Settlement is ~1 second on Base, no protocol fee, no account.
Headers: PAYMENT-REQUIRED → PAYMENT-SIGNATURE → PAYMENT-RESPONSE.
Networks are CAIP-2: Base mainnet is eip155:8453, Base Sepolia eip155:84532.
Schemes: exact (fixed price) or upto (usage-based, EVM only).
Why it matters to us
It is the only clean answer to "how does an autonomous agent pay for something?" No API key to provision, no subscription, no human in the loop. That maps directly onto a P2P agent and any future Ekinoxis agent product.
It is early. Treat it as a bet, not infrastructure — build the paid endpoint so that x402 is one payment path among others, not the only door.
Seller (Next.js)
import { paymentMiddleware } from "@x402/next";
export const middleware = paymentMiddleware(
process.env.DESTINATION_WALLET!, // where USDC lands
{ "/api/score": { price: "$0.01", network: "eip155:8453" } },
{ url: "https://api.cdp.coinbase.com/platform/v2/x402" }, // facilitator
);
Buyer
import { wrapFetchWithPayment } from "@x402/fetch";
const paidFetch = wrapFetchWithPayment(fetch, walletClient);
const res = await paidFetch("https://api.example.com/score");
Rules we apply
- Cap spend per agent run. A buyer wallet with an unbounded loop and a paid endpoint is a money leak with no error message. Budget per session and hard-stop.
- Testnet first —
eip155:84532with faucet USDC (../ekx-circle-usdc/SKILL.md). - Settlement is not delivery. Verify
PAYMENT-RESPONSEbefore treating the resource as paid for; log both sides for reconciliation. - The receiving wallet is a hot wallet. Sweep to treasury; do not accumulate.
- Price in USDC, 6 decimals.
"$0.01"=10000units.
Related: ../ekx-tempo/SKILL.md — MPP is the same idea on Tempo.