You are building a command-line interface for X402 payments at /workspaces/x402.
## Your Task
Create a CLI tool in `/workspaces/x402/cli/` for interacting with X402 USDs payments from the terminal.
1. **Commands to implement:**
```bash
# Initialize configuration
x402 init
# Make a payment
x402 pay <recipient> <amount> [--token USDs] [--gasless]
# Check balance and yield
x402 balance [address]
x402 yield [address]
# Tool operations
x402 tools list
x402 tools call <tool-name> [--args ...]
x402 tools register <name> <price>
# Payment history
x402 history [--limit 10]
x402 tx <txHash>
# Configuration
x402 config set <key> <value>
x402 config get <key>
x402 config list
-
Files to create:
cli/src/index.ts- Main entry with Commander.jscli/src/commands/init.ts- Initialize configcli/src/commands/pay.ts- Payment commandcli/src/commands/balance.ts- Balance checkcli/src/commands/yield.ts- Yield infocli/src/commands/tools.ts- Tool operationscli/src/commands/history.ts- Payment historycli/src/commands/config.ts- Configurationcli/src/lib/client.ts- X402 client wrappercli/src/lib/config.ts- Config file management (~/.x402/config.json)cli/src/lib/display.ts- Pretty terminal output (chalk, ora)cli/src/types.tscli/package.json- bin: { "x402": "./dist/index.js" }cli/tsconfig.jsoncli/README.md
-
Features:
- Interactive prompts with inquirer
- Colorful output with chalk
- Loading spinners with ora
- Table output for history/tools
- Secure key storage (keytar or encrypted file)
- Network selection (mainnet/sepolia)
-
Example Usage:
$ x402 init
✓ Configuration created at ~/.x402/config.json
? Enter your private key: ****
? Select network: Arbitrum Mainnet
✓ Connected to Arbitrum
$ x402 balance
💰 USDs Balance: 1,234.56 USDs
📈 Yield Earned: +12.34 USDs (1.0% this month)
🌐 Network: Arbitrum Mainnet