Payments
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.
Learn more about the protocol at x402.org.
x402 Playground
Try out x402 payments in our live playground
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.