Skip to main content

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

  1. Client requests a resource from a paywalled API.
  2. Server returns HTTP 402 with X-Payment-Required.
  3. Client creates and signs an X402PaymentIntent.
  4. Client retries with X-Payment header.
  5. Payment intent is sequenced and batched.
  6. Batch is committed and later settled on Set Chain L2.
  7. 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.mjs
  • stateset-icommerce/cli/examples/x402_client_real.mjs
  • stateset-icommerce/cli/examples/x402_server_real.mjs

Example: x402 Payment Demo

node stateset-icommerce/cli/examples/x402_payment_demo.mjs

Signed Intent Basics

The intent includes payer/payee, amount, network, validity window, and a signature hash. Signing uses the domain separator X402_PAYMENT_V1 and Ed25519 signatures.