Paying for SMM orders from an agent over x402 (testnet)
How an agent pays for an order over x402: from a wallet to a test payment. Testnet only — USDC on Base Sepolia, live payments are not enabled.
1. What it is and what is not promised
An agent pays for an order over x402: the server answers HTTP 402 with a payment requirement, the agent signs a USDC transfer, a facilitator settles it. Today this is testnet only — USDC on Base Sepolia. Live payments are not enabled.
- Without the x402 environment variables the gateway keeps the dev-only mock rail — nothing changes for local development or tests;
- mainnet USDC is not enabled yet, no real money flows through this path;
- money flows directly agent → provider and never transits the gateway.
2. The receiving wallet
The script creates a wallet and appends three variables to .env (chmod 600, gitignored); the private key is never printed or committed.
node scripts/create-wallet.ts # .env X402_NETWORK=eip155:84532 X402_PAYTO_ADDRESS=0x... # the gateway's receiving address X402_PRIVATE_KEY=0x... # never printed, never committed
For a first probe the same wallet can be both payer and recipient (a self-payment is a valid EIP-3009 transfer). For a realistic flow use a second wallet as the payer.
3. Test USDC and the facilitator
The payer needs test USDC on Base Sepolia — Circle's free faucet issues it (faucet.circle.com). The payer needs no ETH: for the exact scheme the facilitator sponsors the gas of transferWithAuthorization.
X402_FACILITATOR_URL=https://x402.org/facilitator
This is the public testnet facilitator, no auth. Production facilitators (for example Coinbase CDP) require an API key. After boot, GET /v0/capabilities reports paymentMethods: ["x402"], and settling with method: "mock" is rejected in this configuration.
4. Fire a test payment
One script runs the whole flow on the real testnet rail: quote → order → 402 → settle → execution start.
npm run x402:testnet
- quotes the default service of the mock catalog at its minimum quantity;
- creates the order and reads its x402 payment requirement;
- signs an EIP-3009
transferWithAuthorizationwithX402_PRIVATE_KEY; - submits it through the facilitator:
/verify, then/settle; - prints the on-chain tx hash and the execution status.
The catalog here is the mock one (synthetic: true), not real supply. Full instructions: docs/X402_TESTNET.md.
If settlement fails
- facilitator rejection (bad signature, insufficient balance) —
PAYMENT_REQUIREDwith the reason, the order stays inREQUIRES_PAYMENT; settlement_pending— the order moves toSETTLEMENT_PENDINGwith the tx hash: reconcile on chain, never re-pay;- facilitator HTTP 5xx or timeout — a plain error, the payment stays retryable.
Honest limits
- This is a testnet: USDC on Base Sepolia, live payments are not enabled.
- The catalog is mock fixtures, not real supply.
- The npm package and a public image are not published: run the commands from a repository checkout.
Next step: run your own node
A node is a single process serving REST /v0 and MCP /mcp on one port. You need Node.js ≥ 22.18.
The step-by-step guide, node verification and reporting your node live on the “Run a node” page.