> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# x402 Payments with iCommerce

> HTTP-native micropayments with x402, signed off-chain and sequenced on Set L2.

# 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

```bash theme={null}
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.

## Related Documentation

* [Sequencer x402 Payments](/stateset-sequencer-x402)
* [Set L2 Overview](/stateset-set-l2)
