x402 fetch with payment in the thirdweb API

You can now pay for any x402 compatible endpoint using the the new /v1/payments/x402/fetch
API.
What's new
The new /v1/payments/x402/fetch
in the thirdweb API proxies any url, and upon receiving HTTP 402 payment required response, automatically handles the payment with the authenticated wallet.
Query params
url
- target endpoint to fetchfrom
- the wallet address to pay withmethod
- optional HTTP method for the endpoint to fetch (defaults to POST)maxValue
- optional max amount that can be paidasset
- optional payment token, if not specified defaults to the target endpoint payment methodchainId
- optional payment chain, if not specified defaults to the target endpoint payment chain
Request body and headers will be forwarded to the target url.
Usage
You can use this from any language, any platform. Use it with your server wallets (using your project secret key) or with user in-app wallets (using the user JWT).
This makes is much easier to implement x402 payments for apps and agents.
Simply call this endpoint in your frontend or your agent tool to automatically pay for any x402 compatible endpoint.
Learn more
Happy building! ๐ ๏ธ