← Learn

Smoke-test x402 payments on Base Sepolia before mainnet

Prove your agent can complete the x402 handshake with testnet USDC and mock responses before spending real Base mainnet USDC. Query param, assets, facilitator, and a checklist for promoting to production.

Append `?network=base-sepolia` to any Marketplace for AI Agents endpoint to exercise the full x402 402 → X-PAYMENT → 200 flow with Base Sepolia USDC and mock response bodies. Use that sandbox until receipt decoding and spend policy look correct, then drop the override and settle on Base mainnet.

Mainnet mistakes are expensive and noisy. Sepolia lets an agent verify discovery, free-tier behavior, payment signing, and ledger logging without burning real USDC or real upstream quota.

What the sandbox changes

DimensionBase mainnetBase Sepolia (`network=base-sepolia`)
Query overrideomit (default)`network=base-sepolia`
USDC asset`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913``0x036CbD53842c5426634e7929541eC2318f3dCF7e`
Payee`0x05e82e03753c7bc99fb24d10a876cce53f24b7b7`same payTo
Price$0.005 (5000 atomic, 6 decimals)same amount in testnet USDC
Response bodylive upstream datamock data in the documented shape
Facilitatorproduction settlement path`https://x402.org/facilitator` (per `/.well-known/x402`)
Free tier3 calls / agent identitysame global free tier

Confirm live values from https://marketplaceforaiagents.com/.well-known/x402 before signing. Do not hard-code assets from memory — the manifest is the source of truth.

Minimal smoke-test sequence

  • Read discovery: `GET https://marketplaceforaiagents.com/.well-known/x402` and note the `base-sepolia` acceptedPaymentMethods entry.
  • Pick a simple slug with one required param, e.g. `google-search` (`q`) or `youtube-transcripts` (`video_id`). Spec: https://marketplaceforaiagents.com/api/public/v1/openapi.json
  • Call unpaid with the sandbox flag. Prefer a stable User-Agent so free-tier identity is predictable.
  • If you still have free calls, expect `200` + `X-Free-Calls-Remaining`. Burn free calls deliberately or switch identity if you need to force a 402.
  • On `402`, validate `accepts[]`: scheme `exact`, network `base-sepolia`, asset Sepolia USDC, payTo matches policy, maxAmountRequired `5000`.
  • Sign EIP-3009 transferWithAuthorization against Sepolia USDC, base64 the x402 payload, retry with `X-PAYMENT`.
  • On `200`, decode `X-PAYMENT-RESPONSE` and store the transaction / success fields in the agent ledger.
  • Assert the JSON body matches the documented results key even though values are mock.
bash
# 1) Discovery
  curl -s https://marketplaceforaiagents.com/.well-known/x402 | jq '.acceptedPaymentMethods'
  
  # 2) Unpaid sandbox call (uses free tier if remaining)
  curl -si "https://marketplaceforaiagents.com/api/public/v1/google-search?q=x402+smoke&network=base-sepolia"
  
  # 3) After free tier: expect 402 with base-sepolia accepts[]
  # 4) Retry same URL with X-PAYMENT (agent wallet / x402-fetch)
  # curl -si -H "X-PAYMENT: <base64>" \
  #   "https://marketplaceforaiagents.com/api/public/v1/google-search?q=x402+smoke&network=base-sepolia"

What you are proving

CheckPass condition
Param validation`400 missing_required_parameters` lists missing names; fix before paying
Unknown slug`404 unknown_endpoint` → re-read `/.well-known/x402`
402 shape`x402Version`, `error`, and non-empty `accepts[]`
Network gatepolicy rejects `network: base` while you intend Sepolia, and vice versa
Asset gatepolicy rejects any asset other than Sepolia USDC in sandbox mode
Amount gate`maxAmountRequired` ≤ allowlisted atomic cap (5000 today)
Receipt`X-PAYMENT-RESPONSE` base64-decodes; success true; tx hash logged
Body contractresults key present (`organic_results`, `transcripts`, etc.) even with mock data

Upstream outages return `502 upstream_error` and are not charged on mainnet. Sandbox avoids real upstream entirely — if you see a 502 in Sepolia mode, treat it as a gateway bug, not a payment bug.

Wallet and facilitator notes

Fund a dedicated EOA with Base Sepolia USDC (`0x036CbD53842c5426634e7929541eC2318f3dCF7e`). Keep this key separate from the mainnet payer.

EIP-3009 still applies: the agent signs off-chain; a facilitator submits on-chain. The Sepolia acceptedPaymentMethods entry points at `https://x402.org/facilitator`. Your client library (for example `x402-fetch` / `@x402/*`) should pick the facilitator from the 402 / manifest, not from hard-coded URLs in prompts.

  • Never reuse a mainnet-funded hot wallet for smoke tests.
  • Never omit `network=base-sepolia` and assume mock mode — omitting defaults to real mainnet settlement.
  • Never promote to mainnet until policy checks reject wrong network/asset/payTo in automated tests.

Promote to Base mainnet

When the checklist passes:

  • Drop `network=base-sepolia` from the request URL.
  • Switch the wallet client chain to Base mainnet and fund USDC at `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`.
  • Re-run policy against live `accepts[]` from a mainnet 402 (or from `get_payment_requirements` on https://marketplaceforaiagents.com/mcp).
  • Keep the same ledger path — only the network field and asset address change.
ts
// Pseudocode: same payFetch, different network mode
  const sandbox = process.env.X402_SANDBOX === "1";
  const url = new URL("https://marketplaceforaiagents.com/api/public/v1/google-news");
  url.searchParams.set("q", "base usdc");
  if (sandbox) url.searchParams.set("network", "base-sepolia");
  
  const res = await payFetch(url.toString());
  const receipt = res.headers.get("X-PAYMENT-RESPONSE");
  // decode + ledger.write({ network: sandbox ? "base-sepolia" : "base", receipt })

Related entrypoints

  • Manifest: https://marketplaceforaiagents.com/.well-known/x402
  • Catalog: https://marketplaceforaiagents.com/api/public/v1/catalog.json
  • OpenAPI: https://marketplaceforaiagents.com/api/public/v1/openapi.json
  • MCP: https://marketplaceforaiagents.com/mcp
  • Docs: https://marketplaceforaiagents.com/docs
  • Browse: https://marketplaceforaiagents.com/marketplace
  • Protocol explainer: https://marketplaceforaiagents.com/learn/x402-protocol-explained
  • Budget before sign: https://marketplaceforaiagents.com/learn/budget-x402-api-calls
  • MCP connect guide: https://marketplaceforaiagents.com/learn/mcp-x402-marketplace

Sandbox until the receipt path is boring. Then spend mainnet USDC on purpose, not by accident.