Skip to main contentComplete an x402 payment
This tutorial walks you through a full x402 payment from HTTP 402 to receipt verification.
Prerequisites
- Access to a paywalled endpoint that returns HTTP 402
- A signer capable of Ed25519 signatures
- Sequencer endpoint URL
Step 1: Request a protected resource
Call the resource endpoint and capture the X-Payment-Required header.
Step 2: Build and sign an intent
Create an X402PaymentIntent with payer/payee, amount, network, and validity window. Sign with the X402_PAYMENT_V1 domain separator.
Step 3: Retry with X-Payment
Retry the request with the signed intent in the X-Payment header.
Step 4: Sequence the intent
Submit the intent to the sequencer for batching and settlement.
Step 5: Fetch receipt and verify
Request the receipt and verify inclusion proof against the on-chain batch commitment.
Next steps