@x402r/cli makes a single x402 payment from the command line. You point it at an address, provide a signer, and get back the response body plus a settlement transaction hash.
The CLI carries zero provider SDK dependencies. Raw private keys, JSON-RPC signers (Privy, Turnkey, Fireblocks, Safe), and custom signer modules all work through the same interface.
Install
@x402r/cli@0.2.0) for reproducible scripted workflows.
Usage
Signer configuration
Configure exactly one signer source. CLI flags take precedence over environment variables. If the CLI finds zero or more than one source, it exits with code 6.
Environment variable names use no
X402R_ prefix to match Foundry, Hardhat, and x402-reference conventions.
Request options
Supported chains
The CLI reads the chain from the 402 response’saccepts[].network field. Any EVM chain known to viem/chains works, including Base and Base Sepolia. For chain IDs viem/chains does not recognize, pass --rpc <url> with an RPC endpoint.
Exit codes
Examples
Raw private key
JSON-RPC signer
Any endpoint that speakseth_signTypedData_v4 works: Privy wallet RPC, Turnkey, Fireblocks, Safe, a local cast wallet endpoint, or a hardware wallet behind an RPC bridge.
Custom module (Privy)
privy-signer.js
Custom module (Coinbase CDP)
cdp-signer.js
JSON output
With--json, the CLI writes a single JSON envelope to stdout:
signer field when the endpoint returned a non-402 response (the CLI sent no payment).
Signer module contract
A custom signer module must default-export a factory function with the signature() => Promise<Account>. The returned object must be a viem Account with at least address and signTypedData. The CLI only needs typed-data signatures; the facilitator broadcasts the transaction.
Programmatic usage
You can also use thepay function and resolveSigner directly from TypeScript:
Exports
The@x402r/cli package exports:
Next steps
Merchant guide
Accept payments and manage escrow releases.
Examples
Runnable examples for every SDK operation.
