x402 Payments with iCommerce
x402 is an HTTP-native payment protocol used by iCommerce agents. It relies on HTTP 402 responses and signed payment intents that are sequenced and settled through the StateSet Sequencer.Protocol Flow
- Client requests a resource from a paywalled API.
- Server returns HTTP 402 with
X-Payment-Required. - Client creates and signs an
X402PaymentIntent. - Client retries with
X-Paymentheader. - Payment intent is sequenced and batched.
- Batch is committed and later settled on Set Chain L2.
- The server verifies payment using inclusion proofs.
iCommerce Implementation
The iCommerce CLI includes x402 helpers and demos:stateset-icommerce/cli/src/x402/*stateset-icommerce/cli/examples/x402_payment_demo.mjsstateset-icommerce/cli/examples/x402_client_real.mjsstateset-icommerce/cli/examples/x402_server_real.mjs
Example: x402 Payment Demo
Signed Intent Basics
The intent includes payer/payee, amount, network, validity window, and a signature hash. Signing uses the domain separatorX402_PAYMENT_V1 and Ed25519 signatures.