x402 · USDC on Base + Solana

x402-agent-sandbox

Three sandbox merchants that speak the suite's exact response contracts. Rehearse the whole book-and-buy flow for $0.003 a run, then point the same code at the real thing.

git clone https://github.com/nirholas/x402-agent-sandbox && npm install && npm run dev

Pricing

RoutePriceWhat you get back
GET /townfreeDirectory of the three merchants, their routes, prices, and what each one mirrors. Start here.
POST /restaurant/book$0.001Signed reservation confirmation in the x402-tablebook schema — table, refund terms, cancel token, base64 ICS invite.
POST /hotel/book$0.001Signed lodging confirmation — room, nightly + total price, refund terms, cancel token, base64 ICS invite.
POST /store/buy$0.001Signed artifact in the x402-storefront envelope — digital download URL + license, or order confirmation + fulfillment record.
reads & cancelsfree/restaurant/availability, /hotel/search, /store/catalog, both cancel routes, /store/download/:token, /verify.

How x402 works here

1 · 402

Request

Call a paid route. The server answers 402 Payment Required with an accepts array holding both rails.

2 · Sign

Pay

The 402 offers two rails — USDC on Base and USDC on Solana. Your client signs whichever one its wallet supports and retries with X-PAYMENT.

3 · Settle

Verify

That rail's facilitator verifies and settles on-chain. The server holds no key and pays no gas.

4 · 200

Artifact

The signed confirmation arrives in the response body — the same shape the real merchant returns — with the receipt in X-PAYMENT-RESPONSE.

Quickstart

npm install && npm run dev                    # the town on :4038, both rails live
open http://localhost:4038/                   # human checkout demo

# agent side — the whole flow, three paid calls, $0.003 total
PRIVATE_KEY=0xAgentWallet npx tsx examples/agent-client.ts

Payment rails

RailNetworkAssetPays toFacilitator
EVMbase-sepolia (default) · baseUSDC0x40252CFDF8B20Ed757D61ff157719F33Ec332402x402.org/facilitator
Solanasolana (default) · solana-devnetUSDCWwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwWfacilitator.payai.network

Both entries appear in every 402. Pay in USDC on Base or Solana — your client picks the rail. Set PAY_TO_ADDRESS / SOLANA_PAY_TO_ADDRESS to receive the funds yourself.

What each merchant mirrors

Sandbox merchantRoutesMirrors
Chez Sandbox/restaurant/availability · /restaurant/book · /restaurant/cancel/:idx402-tablebook
The Sandbox Inn/hotel/search · /hotel/book · /hotel/cancel/:idx402-hotel-search offers + the suite lodging confirmation
Sandbox Supply Co./store/catalog · /store/buy · /store/download/:tokenx402-storefront

Field for field, not just in spirit. Client code written against this sandbox ports 1:1 to the real services — change the base URL and the route prefix, nothing else.

Deterministic by design

Confirmations are seeded by the request body. The same booking request always returns the same reservationId, the same cancelToken, and the same table or room assignment — only timestamps move. Assert on those fields in a test suite and they stay green; replay a failing conversation and it fails identically.