Skip to main content
Using a SHHH V8.4 wallet? This page covers X402Client, which signs payments for legacy CHIPI v29 and READY (Argent X) wallets. SHHH V8.4 wallets — the default for new wallets since v14.5.0 — use X402ShhhClient instead, because V8.4 rejects the raw {r, s} signature shape X402Client produces.

Overview

The x402 client automatically handles HTTP 402 responses. When a server requires payment, the client:
  1. Parses the payment requirement from the PAYMENT-REQUIRED header
  2. Validates the amount against your configured limits
  3. Signs the payment using your Starknet account
  4. Retries the request with the X-PAYMENT header

React — useX402Payment Hook

The easiest way to use x402 in a React/Next.js app:

Hook Configuration

Hook Return Values

Node.js — X402Client

For server-side or CLI applications:

Configuration Options

Always set maxPaymentAmount in production. Without it, a compromised or malicious server could request an arbitrarily large payment. Set it to the maximum amount you expect to pay per request (e.g. "1.00" for $1 USDC).

Python

Safety Features

Amount Limits

Always set maxPaymentAmount to prevent unexpected charges:
If a server requests more than your limit, the client throws an error instead of signing.

Recipient Whitelist

Restrict which servers can charge you:

Asset Validation

The client only accepts payments in native USDC on Starknet mainnet. Requests for any other token are automatically rejected.

Error Handling