# ScanPay x402 quickstart ScanPay is pay-per-call: request an endpoint, get HTTP 402 with an `accepts` list, sign the USDC payment that matches one entry, retry with `PAYMENT-SIGNATURE`, and read the JSON plus the signed `X-Delivery-Receipt`. ## 1. Smoke-test your wallet and an x402 client for $0.0001 POST https://scanpay-edge.alextaghiashvili.workers.dev/api/v1/canary (or GET with any query) Body: anything. The response echoes it and returns both network accepts. This proves signing, facilitator settlement and delivery receipts end to end. ## 2. TypeScript (x402-fetch) ```ts import { wrapFetchWithPayment, decodeXPaymentResponse } from "x402-fetch"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); const fetchWithPay = wrapFetchWithPayment(fetch, account); const res = await fetchWithPay("https://scanpay-edge.alextaghiashvili.workers.dev/api/v1/perp-funding", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ symbol: "BTC" }) }); const data = await res.json(); const receipt = decodeXPaymentResponse(res.headers.get("x-payment-response") || ""); console.log(data, receipt); ``` ## 3. Python (x402 client) ```py import os, requests from eth_account import Account from x402.http.x402_http_client_base import encode_payment_signature_header from x402.mechanisms.evm.exact.client import ExactEvmScheme from x402.schemas import PaymentPayload, PaymentRequirements acct = Account.from_key(os.environ["PRIVATE_KEY"]) url = "https://scanpay-edge.alextaghiashvili.workers.dev/api/v1/canary" r = requests.post(url, json={"ping": "quickstart"}) quote = r.headers["PAYMENT-REQUIRED"] # base64 JSON import base64, json accept = next(a for a in json.loads(base64.b64decode(quote))["accepts"] if a["network"] == "eip155:8453") req = PaymentRequirements(scheme=accept["scheme"], network=accept["network"], asset=accept["asset"], amount=accept["amount"], pay_to=accept["payTo"], max_timeout_seconds=accept.get("maxTimeoutSeconds", 300), extra=accept.get("extra")) inner = ExactEvmScheme(acct).create_payment_payload(req) payload = PaymentPayload(x402_version=2, payload=inner, accepted=req) r = requests.post(url, json={"ping": "quickstart"}, headers={"PAYMENT-SIGNATURE": encode_payment_signature_header(payload)}) print(r.status_code, r.json()) ``` ## 4. Hero endpoints (see /llms.txt for all 58) - POST /v1/chat/completions ($0.002) — OpenAI-compatible chat (point an OpenAI base_url at https://scanpay-edge.alextaghiashvili.workers.dev/v1). - POST /v1/chat/nano ($0.002) — short, high-volume chat. - POST /api/v1/perp-funding ($0.001) — Binance/Bybit/Hyperliquid funding + arb spread. - POST /api/v1/crypto-price ($0.001) — spot prices. - POST /api/v1/web-search ($0.01) — search results. - POST /api/v1/spl-mint-audit ($0.001) — Solana SPL mint authorities/risk. - POST /api/v1/receipt-verify ($0.001) — verify a delivery receipt before acting on it. ## 5. Verify what you got Every paid 200 carries `X-Delivery-Receipt` = base64 of {receipt, attestation}, EIP-191 signed. POST the receipt to /api/v1/receipt-verify ($0.001) or verify it yourself against https://scanpay-edge.alextaghiashvili.workers.dev/.well-known/attestation-address. Every response also has `Server-Timing: app;dur=...`. ## 6. Legacy x402 v1 clients (Base only) If your stack still speaks x402 v1, send the legacy header instead of PAYMENT-SIGNATURE: X-PAYMENT: base64({"x402Version":1,"scheme":"exact","network":"base", "payload":{"signature":"0x...","authorization":{...}}}) ScanPay converts it server-side to a v2 payment, settles on Base, and returns both `X-PAYMENT-RESPONSE` (legacy) and `PAYMENT-RESPONSE` (v2). Solana v1 is not supported yet. No signup, no API key, no free tier. Base USDC 0x1E04f5046500e5369E17AF993Dc60aC29D83efc9; Solana SPL-USDC N6ZJxx4DAGbDYv3HbVYXso3yFyqprrxPPzdKsZpHHX9.