X402 Payment Encoder
Build agent-to-agent payment payloads for Ritual Chain — 100% client-side
Payment parameters
Encoded payment payload
{
"version": "x402/1.0",
"payer": "0x1234567890123456789012345678901234567890",
"payee": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"amount": "10000000000000000",
"token": "RITUAL",
"chainId": 1979,
"resource": "https://api.example-agent.com/v1/inference",
"timestamp": 1788026720,
"expiresAt": 1788027020,
"nonce": "0xa8fcca798a2e5991f7aaec00cae18e48",
"signature": "(signed by payer — see signing instructions below)",
"scheme": "https://x402.org/schemes/evm"
}HTTP 402 challenge (server response)
{
"X-402-Challenge": {
"scheme": "https://x402.org/schemes/evm",
"network": 1979,
"payee": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"resource": "https://api.example-agent.com/v1/inference",
"maxAmountRequired": "10000000000000000",
"asset": "RITUAL"
}
}The payee agent returns this in the HTTP response when a payment is required.
Payment header (client request)
{
"X-402-Payment": {
"version": "x402/1.0",
"payer": "0x1234567890123456789012345678901234567890",
"payee": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"amount": "10000000000000000",
"token": "RITUAL",
"chainId": 1979,
"resource": "https://api.example-agent.com/v1/inference",
"timestamp": 1788026720,
"expiresAt": 1788027020,
"nonce": "0xa8fcca798a2e5991f7aaec00cae18e48",
"signature": "(signed by payer — see signing instructions below)",
"scheme": "https://x402.org/schemes/evm"
}
}The payer agent sends this header with the retry request after receiving a 402 challenge.
About the X402 Encoder
X402 is the payment protocol for AI agents — HTTP 402 (Payment Required) turned into a machine-readable payment flow. When an agent requests a paid resource, the server responds with a 402 challenge, the agent constructs a payment, and the retry request includes the payment header.
On Ritual Chain, X402 payments run on the HTTP precompile, letting agents pay for API calls, LLM inference, and data without human intervention. This encoder builds valid X402 payloads, HTTP challenges, and payment headers.
- Encodes full X402 payment payloads with auto-generated nonces
- Generates HTTP 402 challenge responses for payee agents
- Generates payment headers for payer agent retry requests
- Decode mode for inspecting existing X402 payments
- All computation happens locally
How to use
- Enter the payer and payee addresses.
- Set the amount (in wei) and token.
- Specify the resource URL being paid for.
- Copy the encoded payment, challenge, or header format.
Frequently Asked Questions
What is HTTP 402? ▾
HTTP 402 Payment Required is a status code defined in the original HTTP spec but never widely used. X402 repurposes it: servers return a structured 402 challenge describing what payment is needed, and clients retry with a payment header attached.
How do agents pay each other on Ritual? ▾
The payer agent calls the HTTP precompile (0x0801) which handles X402 natively. The payee specifies a price for their resource, the payer deposits RITUAL into their RitualWallet, and the chain settles the payment atomically with the resource delivery.
Is this tool free to use? ▾
Yes! This tool is 100% free. No signup, no credit card, no limits. It's part of Formatho's privacy-first developer toolkit.
Is my data safe? Does this tool send data to a server? ▾
Absolutely. This tool runs entirely in your browser. Your data never leaves your device. Zero server-side processing, zero tracking.