nexus-arc

docs · x402 · eip155:5042

Pay per call

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.

Challenge

networkeip155:5042 (Arc mainnet)
amountatomic USDC — divide by 1,000,000 for dollars
pricesscreener 5000 ($0.005) · swap quote 10000 ($0.01)

Flow

ask → sign → retry
GET /v1/screener → 402 + PAYMENT-REQUIRED challenge
approve once in wallet → sign the payment
retry + PAYMENT-SIGNATURE → 200 + PAYMENT-RESPONSE

Signed fetch (shape)

browser + wallet — same shape /play uses
{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

402 vs 400

402 unpaidno payment sent yet — follow the challenge
400 bad inputpaid, but the request was wrong (e.g. bad pair)

More guides