A CLI tool for HTTP GET requests with automatic x402 payment support. When a server responds with HTTP 402 Payment Required, x402get displays the price, checks your wallet balance, asks for confirmation, signs an EIP-3009 TransferWithAuthorization, and retries the request with payment.
# Run directly with npx
npx x402get https://google.com
# Or install globally
npm install -g x402getgit clone https://github.com/anders94/x402get.git
cd x402get
npm install
npm run build
node dist/cli.js x402getRequires Node.js 20+ (for native fetch).
x402get url [options]| Option | Description |
|---|---|
-k, --private-key <key> |
Private key for signing payments |
-r, --rpc <url> |
RPC endpoint URL |
-o, --output <file> |
Save response body to a file |
-h, --help |
Show help |
| Variable | Description |
|---|---|
PRIVATE_KEY |
Default private key (overridden by --private-key) |
RPC_ENDPOINT |
Default RPC URL (overridden by --rpc) |
x402get https://httpbin.org/getexport PRIVATE_KEY=0xabc123...
x402get https://api.example.com/paid-endpointOutput:
Fetching https://api.example.com/paid-endpoint...
=== x402 Payment Required ===
Resource: https://api.example.com/paid-endpoint
Description: Premium API access
Price: 0.01 USDC
Network: Base
Pay to: 0x1234...abcd
Wallet: 0xabcd...1234
Balance: 5.00 USDC
Proceed with payment? [y/N] y
Signing payment...
Retrying request with payment...
Payment tx: 0xdeadbeef...
{"data": "the paid content"}
Done.
All informational output goes to stderr, so stdout is clean for piping:
x402get https://api.example.com/paid-data > data.jsonx402get https://api.example.com/paid-image -o image.pngx402get https://api.example.com/resource --rpc https://my-rpc.example.com- GET request — x402get fetches the URL normally.
- 200 OK — The response body is printed to stdout (text) or saved to a file (binary).
- 402 Payment Required — The server includes a base64-encoded
PAYMENT-REQUIREDheader describing accepted payment methods. - Challenge parsing — x402get decodes the challenge and selects a compatible
eip3009(EIP-3009TransferWithAuthorization) payment option. - Balance check — The tool queries the ERC-20 token contract for your wallet's balance.
- Confirmation — A summary is displayed and you are prompted to approve or cancel.
- EIP-712 signing — x402get signs a
TransferWithAuthorizationmessage using EIP-712 typed data. No on-chain transaction is sent by the client — the server submits it. - Retry — The original request is retried with a
Payment-Signatureheader containing the signed authorization. - Response — The paid content is returned. If the server includes a
PAYMENT-RESPONSEheader with a transaction hash, it is displayed on stderr.
x402get includes built-in RPC endpoints and USDC token addresses for these networks:
| Chain | Chain ID | Default RPC |
|---|---|---|
| Ethereum | 1 | https://eth.llamarpc.com |
| Base | 8453 | https://mainnet.base.org |
| Base Sepolia | 84532 | https://sepolia.base.org |
| Radius | 723 | https://rpc.radiustech.xyz |
| Radius Testnet | 72344 | https://rpc-testnet.radiustech.xyz |
| Polygon | 137 | https://polygon-rpc.com |
Any EVM chain using the CAIP-2 eip155:<chainId> format is supported — provide the RPC endpoint via --rpc or RPC_ENDPOINT for chains not listed above.
The x402 protocol enables machine-to-machine payments over HTTP. It extends the HTTP 402 status code with a structured payment challenge/response flow:
- Server returns 402 with a
PAYMENT-REQUIREDheader (base64-encoded JSON) listing accepted payment schemes, token addresses, amounts, and chain identifiers. - Client signs an off-chain authorization (EIP-3009
TransferWithAuthorization) and sends it back in aPAYMENT-SIGNATUREheader. - Server verifies the signature, submits the token transfer on-chain, and returns the requested resource along with a
PAYMENT-RESPONSEheader containing the transaction hash.
- Private keys — Your private key never leaves your machine. It is used only to sign an EIP-712 typed data message. No raw transactions are broadcast by the client.
- Confirmation — Every payment requires explicit
yconfirmation before signing. - Amount visibility — The exact token amount, recipient, network, and your balance are displayed before you confirm.
- No blind signing — The EIP-712 domain and message fields are fully specified by the server's challenge and can be inspected.
MIT