Get /weather without X-PAYMENT
When calling a service without a valid payment attached (meaning there no X-PAYMENT header is set), the server responds with HTTP 402 error providing pricing and payment details:
{
"x402Version": 1,
"error": "X-PAYMENT header is required",
"accepts": [
{
"scheme": "exact",
"network": "base-sepolia",
"maxAmountRequired": "1000",
"resource": "http://localhost:4021/weather",
"description": "",
"mimeType": "",
"payTo": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
"maxTimeoutSeconds": 60,
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"extra": {
"name": "USDC",
"version": "2"
}
}
]
}This response is described here https://github.com/coinbase/x402?tab=readme-ov-file#type-specifications with Payment Required Response & payment Requirements. In our project, we have two objects to deal with it : PaymentRequired & PaymentRequirement.
Last updated