docs · x402 · eip155:5042
Every paid endpoint speaks x402 exact: the first call is free and returns the price; you sign; the retry returns the answer. No accounts, no keys — payment is the auth.
GET /v1/screener → 402 + PAYMENT-REQUIRED challenge approve once in wallet → sign the payment retry + PAYMENT-SIGNATURE → 200 + PAYMENT-RESPONSE
{const r1 = await fetch("/v1/swap", [METHOD_POST]);
const c = (await r1.json()).accepts[0]; // 402 challenge
const sig = await window.ethereum.request([SIGN_TYPED]);
const header = btoa(JSON.stringify([PAYMENT_OBJ]));
await fetch("/v1/swap", [RETRY_POST]); // → 200 + quote
// Full working code: open /play.js — same shape, exact bytes.
// METHOD_POST = method POST + JSON body tokenIn/tokenOut/amountIn
// SIGN_TYPED = eth_signTypedData_v4 Permit2 witness (chain 5042)
// PAYMENT_OBJ = x402Version 2, scheme exact, payload signature +
// permit2Authorization, accepted challenge
// RETRY_POST = same body + PAYMENT-SIGNATURE header