x402
x402 Payments
x402 is an open-source protocol that turns the dormant HTTP 402 Payment Required status code into a fully-featured, on-chain payment layer for APIs, websites, and autonomous agents.
x402 Playground
Try out x402 payments in our live playground
The thirdweb x402 client/server stack supports payments on 170+ EVM chains.
The payment token must support either:
- ERC-2612 permit (most ERC20 tokens)
- ERC-3009 sign with authorization (USDC on all chains)
wrapFetchWithPayment wraps the native fetch API to automatically handle 402 Payment Required responses from any x402-compatible API:
You can also use the thirdweb API to fetch any x402 compatible endpoint and pay for it with the authenticated wallet. See the client side docs for more details.
To make your API calls payable, use the settlePayment function in a middleware or endpoint:
You can also create middlewares to handle payment for multiple endpoints, see the server side docs for more details. The facilitator handles settling the payment onchain using your own server wallet.