|
| 1 | +--- |
| 2 | +name: x402-proxy |
| 3 | +description: Use x402-proxy CLI for consuming and debugging x402 paid APIs. Use this skill when testing x402 endpoints, configuring MCP payment proxies for AI agents, managing x402 wallets, or scripting paid HTTP requests. Triggers on x402-proxy, npx x402-proxy, x402 endpoint testing, paid API debugging, MCP payment proxy, x402 wallet management, or any mention of auto-paying HTTP 402 responses. |
| 4 | +--- |
| 5 | + |
| 6 | +# x402-proxy |
| 7 | + |
| 8 | +`curl` for x402 paid APIs. Auto-pays HTTP 402 responses with USDC on Base and Solana. |
| 9 | + |
| 10 | +## Quick start |
| 11 | + |
| 12 | +```bash |
| 13 | +npx x402-proxy https://twitter.surf.cascade.fyi/users/cascade_fyi |
| 14 | +``` |
| 15 | + |
| 16 | +First run auto-creates a wallet. No setup needed. |
| 17 | + |
| 18 | +## HTTP requests |
| 19 | + |
| 20 | +```bash |
| 21 | +# GET - body to stdout, payment info to stderr |
| 22 | +npx x402-proxy https://api.example.com/resource |
| 23 | + |
| 24 | +# POST with body and headers |
| 25 | +npx x402-proxy --method POST \ |
| 26 | + --header "Content-Type: application/json" \ |
| 27 | + --body '{"query":"example"}' \ |
| 28 | + https://api.example.com/search |
| 29 | + |
| 30 | +# Force a specific chain |
| 31 | +npx x402-proxy --network solana https://api.example.com/data |
| 32 | + |
| 33 | +# Pipe-safe - only response body on stdout |
| 34 | +npx x402-proxy https://api.example.com/data | jq '.results' |
| 35 | + |
| 36 | +# Save response to file |
| 37 | +npx x402-proxy https://api.example.com/data > response.json |
| 38 | +``` |
| 39 | + |
| 40 | +## Commands |
| 41 | + |
| 42 | +``` |
| 43 | +x402-proxy <url> # paid HTTP request (default) |
| 44 | +x402-proxy mcp <url> # MCP stdio proxy for AI agents |
| 45 | +x402-proxy setup # wallet onboarding wizard |
| 46 | +x402-proxy setup --force # re-run setup (overwrite existing wallet) |
| 47 | +x402-proxy status # config + wallet + daily spend summary |
| 48 | +x402-proxy wallet # show addresses and USDC balances |
| 49 | +x402-proxy wallet history # payment log |
| 50 | +x402-proxy wallet history --limit 5 # last 5 payments |
| 51 | +x402-proxy wallet history --json # machine-readable output |
| 52 | +x402-proxy wallet export-key evm # bare EVM private key to stdout |
| 53 | +x402-proxy wallet export-key solana # bare Solana private key to stdout |
| 54 | +x402-proxy wallet export-key mnemonic # bare mnemonic to stdout |
| 55 | +``` |
| 56 | + |
| 57 | +## Fetch flags |
| 58 | + |
| 59 | +``` |
| 60 | +--method, -X <METHOD> HTTP method (default: GET) |
| 61 | +--header, -H <KEY:VALUE> Add request header (repeatable) |
| 62 | +--body, -d <DATA> Request body (string or @file) |
| 63 | +--network <base|solana> Force payment on this chain |
| 64 | +``` |
| 65 | + |
| 66 | +## MCP proxy for AI agents |
| 67 | + |
| 68 | +Drop into Claude, Cursor, or any MCP client config: |
| 69 | + |
| 70 | +```json |
| 71 | +{ |
| 72 | + "mcpServers": { |
| 73 | + "paid-service": { |
| 74 | + "command": "npx", |
| 75 | + "args": ["x402-proxy", "mcp", "https://mcp.example.com/sse"], |
| 76 | + "env": { |
| 77 | + "X402_PROXY_WALLET_MNEMONIC": "your 24 words here" |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +The proxy intercepts 402 responses, pays automatically, forwards the result. Supports StreamableHTTP and SSE. |
| 85 | + |
| 86 | +## Wallet & env vars |
| 87 | + |
| 88 | +One BIP-39 mnemonic derives both Solana and EVM keypairs. Auto-detects which chain based on USDC balance. |
| 89 | + |
| 90 | +``` |
| 91 | +X402_PROXY_WALLET_MNEMONIC # BIP-39 mnemonic (derives both chains) |
| 92 | +X402_PROXY_WALLET_EVM_KEY # EVM private key (hex, 0x optional) |
| 93 | +X402_PROXY_WALLET_SOLANA_KEY # Solana private key (base58 or JSON array) |
| 94 | +``` |
| 95 | + |
| 96 | +Resolution: flags > env vars > mnemonic env > `~/.config/x402-proxy/wallet.json` |
| 97 | + |
| 98 | +Pipe-safe export for scripting: |
| 99 | + |
| 100 | +```bash |
| 101 | +MY_KEY=$(npx x402-proxy wallet export-key evm) |
| 102 | +MY_MNEMONIC=$(npx x402-proxy wallet export-key mnemonic) |
| 103 | +``` |
| 104 | + |
| 105 | +## Config |
| 106 | + |
| 107 | +Lives at `~/.config/x402-proxy/` (or `$XDG_CONFIG_HOME/x402-proxy/`): |
| 108 | + |
| 109 | +```yaml |
| 110 | +# config.yaml |
| 111 | +defaultNetwork: base # or "solana" |
| 112 | +spendLimitDaily: 10 # USDC daily cap |
| 113 | +spendLimitPerTx: 1 # USDC per-request cap |
| 114 | +``` |
| 115 | +
|
| 116 | +Also supports JSONC and JSON config files. Wallet stored in `wallet.json` (mode 0600), payments logged to `history.jsonl`. |
| 117 | + |
| 118 | +## Testing & debugging x402 services |
| 119 | + |
| 120 | +```bash |
| 121 | +# Smoke test an endpoint |
| 122 | +npx x402-proxy https://your-service.com/paid-route |
| 123 | +
|
| 124 | +# Test both chains |
| 125 | +npx x402-proxy --network base https://your-service.com/route |
| 126 | +npx x402-proxy --network solana https://your-service.com/route |
| 127 | +
|
| 128 | +# Batch test |
| 129 | +for route in /users/test /tweets/search /v1/crawl; do |
| 130 | + echo "--- $route ---" |
| 131 | + npx x402-proxy "https://your-service.com$route" 2>/dev/null | head -c 200 |
| 132 | + echo |
| 133 | +done |
| 134 | +
|
| 135 | +# Check what you spent |
| 136 | +npx x402-proxy wallet history --limit 5 |
| 137 | +npx x402-proxy status |
| 138 | +``` |
| 139 | + |
| 140 | +stdout = response body, stderr = payment info. Pipes, redirects, and `jq` all work cleanly. |
| 141 | + |
| 142 | +## Library API |
| 143 | + |
| 144 | +For programmatic use in Node.js apps, read `references/library.md`. |
0 commit comments