{"uid":"cap_IYpnDWPXmkraHSAwysw-O","slug":"x402-dev-tools-build-paymentrequired-object-7cae3ba9","name":"x402 Dev Tools – Build PaymentRequired Object","description":"Builds an x402 v2 PaymentRequired object for a price in dollars on one or more networks, with the right USDC contract, atomic amount and EIP-712 domain (name and version) for each, plus the base64 PAYMENT-REQUIRED header value to send with the 402.","url":"https://dev.kagurazaka.dev/v1/requirements?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"pay_to":{"type":"string","description":"the address that receives the payment"},"networks":{"type":"array","items":{"type":"string"},"description":"CAIP-2 ids or v1 names (default eip155:8453); known: eip155:8453, eip155:84532, eip155:1, eip155:137, eip155:42161, eip155:10, eip155:43114"},"resource":{"type":"string","description":"the https URL being sold"},"mime_type":{"type":"string","description":"default application/json"},"price_usd":{"type":"number","description":"price in dollars, up to 6 decimals"},"description":{"type":"string"},"max_timeout_seconds":{"type":"integer","description":"default 300"}}},"responseSchema":{"type":"json","example":{"header":"eyJ4NDAyVmVyc2lvbiI6Mi...","payment_required":{"error":"Payment required","accepts":[{"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","extra":{"name":"USD Coin","version":"2"},"payTo":"0xe6f7508ab572a4dc9c7486ea017b100d83f3c3f8","amount":"1000","scheme":"exact","network":"eip155:8453","maxTimeoutSeconds":300}],"resource":{"url":"https://api.example.com/v1/weather","mimeType":"application/json","description":""},"x402Version":2}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_uPIE31peq7zdXj3L1nn2m","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates a fully-formed x402 v2 PaymentRequired object and base64 PAYMENT-REQUIRED header value for a given USD price across one or more networks, with correct USDC contract addresses, atomic amounts, and EIP-712 domain info.","exampleAgentPrompt":"Build me an x402 v2 PaymentRequired object for my API at https://api.myservice.com/v1/data — I want to charge $0.05 USD, send payments to 0xe6f7508ab572a4dc9c7486ea017b100d83f3c3f8, and support both Base (eip155:8453) and Arbitrum (eip155:42161). Give me the base64 header value and the full payment_required object.","exampleUseCases":[{"title":"Gate a JSON API behind x402","prompt":"I'm launching a paid weather API at https://api.myweather.com/v1/forecast and want to charge $0.002 per call in USDC on Base — can you build me the x402 v2 PaymentRequired object and the base64 PAYMENT-REQUIRED header I need to return with my 402 response? My wallet is 0xAbC123...def456."},{"title":"Multi-network payment setup","prompt":"I need to sell access to https://api.myai.io/v1/summarize for $0.01 USD and want to accept USDC on Base, Arbitrum, and Optimism. Can you generate the x402 v2 PaymentRequired object with all three networks and the correct USDC contracts and atomic amounts, plus the base64 header value?"},{"title":"Quick x402 header for testing","prompt":"I'm testing x402 v2 integration and need a sample PaymentRequired object for https://dev.myapp.com/api/premium priced at $0.001 USD on the Base Sepolia testnet (eip155:84532) — payments go to 0x1234567890abcdef1234567890abcdef12345678. What's the base64 PAYMENT-REQUIRED header I should return?"}],"resultDescription":"Returns a JSON object containing: (1) a base64-encoded `header` string ready to send as the PAYMENT-REQUIRED HTTP header, and (2) a fully structured `payment_required` object including the x402Version, resource URL and MIME type, and an `accepts` array where each entry has the correct USDC asset contract address, EIP-712 domain (name and version), payTo address, atomic USDC amount derived from the USD price, network CAIP-2 ID, scheme, and maxTimeoutSeconds — one entry per requested network.","failureModes":["Invalid or unsupported CAIP-2 network ID returns an error listing known networks","Missing required fields (pay_to, price_usd, resource) result in a 400 validation error","price_usd with more than 6 decimal places may be rejected or rounded","Non-HTTPS resource URL may be rejected as x402 requires HTTPS resources","Malformed Ethereum address in pay_to causes a validation failure"],"whenToPreferThis":"Use this endpoint when you are building or testing an x402 v2 compliant API seller and need to programmatically generate correct PaymentRequired objects without manually computing atomic USDC amounts, looking up USDC contract addresses per network, or constructing EIP-712 domain strings. It is especially useful for multi-network setups where each network has different contract addresses and token decimals. Prefer this over manual construction or generic x402 libraries when you want a single call to produce a ready-to-use base64 header value.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T12:32:22.776Z","isFirstParty":false,"canonicalSlug":"x402-dev-tools-build-paymentrequired-object-7cae3ba9"}