Install the x402 server library for your runtime (npm install x402 for Node/Express, or pip install x402 for Python/FastAPI); the reference implementations are published at github.com/coinbase/x402 under Apache 2.0.
Add the x402 middleware to your route: on an unauthenticated request, return HTTP 402 with payment instructions encoded in the X402-Payment-Required header specifying accepted token (e.g., USDC on Base), amount, and your receiving wallet address.
Configure a facilitator (Coinbase CDP or Cloudflare's x402 edge) to verify incoming payment proofs; the facilitator checks on-chain settlement and returns a verification token to your server.
On the client's retry request (which carries the X402-Payment header with the signed payment payload), call facilitator.verify() and, if valid, serve the protected resource with a 200 OK and include the receipt in the X402-Receipt response header.
Test end-to-end in a local sandbox using the x402 testnet mode with USDC on Base Sepolia before pointing to mainnet USDC.
Known gotchas
The x402 specification is governed by the Linux Foundation x402 Foundation (launched April 2026) alongside Coinbase; the canonical spec lives at x402.org, not the original Coinbase CDP docs alone.
Solana Foundation joined the x402 initiative in April 2026, adding SPL token support; if your server only accepts ERC-20 USDC, agents using Solana wallets will be unable to pay.
Do not skip facilitator verification and trust the payment header alone; a malicious agent could forge a payment header without actual on-chain settlement.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp