AgnicPay

CLI Tool

Command-line interface for AgnicPay wallet operations

CLI Tool

The agnic CLI lets you manage your AgnicPay wallet, make payments, and trade tokens directly from the terminal. It's designed for AI agents, scripts, and developers who prefer the command line.


Installation

npx agnic --help

Or install globally:

npm install -g agnic

Authentication

The CLI supports three authentication methods (in priority order):

  1. --token flag — passed directly on each command
  2. AGNIC_TOKEN env var — set in your shell environment
  3. Stored token — saved locally via agnic auth login

Login with Email OTP

# Step 1: Request OTP code
agnic auth login [email protected]
# Output: Verification code sent! Flow ID: abc123...
 
# Step 2: Enter code from email
agnic auth verify abc123 847291
# Output: Authenticated as [email protected]

Using Environment Variable

export AGNIC_TOKEN=agnic_tok_sk_live_abc123...
agnic balance

Using Token Flag

agnic balance --token agnic_tok_sk_live_abc123...

Logout

agnic auth logout

Commands

agnic status

Check authentication and wallet status.

agnic status
# User ID: usr_abc123
# Email: [email protected]
# Wallet: 0x046906b3...

agnic balance

Check USDC balance across networks.

# All networks
agnic balance
# Network    Currency   Balance
# base       USDC       $125.50
# solana     USDC       $0.00
 
# Specific network
agnic balance --network base
# base: $125.50 USDC

agnic address

Show your wallet address.

agnic address
# 0x046906b3cd9d73bf85eb01d795d333b364b75842

agnic send

Send USDC to a wallet address.

agnic send 5.00 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7
# Sending 5.00 USDC to 0x742d35...f0bEb7...
# Transfer complete!
# Amount: $5.00 USDC
# To: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7
# Tx: 0xabc123...

Options:

  • --network <network> — Network (default: base)
  • --memo <text> — Transaction memo

agnic trade

Trade/swap tokens on Base.

# Preview a trade
agnic trade 10 usdc eth --dry-run
# Trade Quote:
#   Sell: 10 USDC
#   Buy:  0.00396 ETH
#   Price: 2525.25
 
# Execute
agnic trade 10 usdc eth
# Swapping 10 USDC -> ETH on Base...
# Trade complete!
#   Sold: 10 USDC
#   Got:  0.00396 ETH
#   Tx: 0xabc123...

Options:

  • --slippage <percent> — Max slippage percentage (default: 1.0)
  • --dry-run — Show quote without executing

Search for X402-enabled APIs.

agnic x402 search "sentiment analysis"
# Found 3 API(s):
#   1. Sentiment Pro
#      Real-time sentiment analysis
#      Price: $0.001 /request

Options:

  • --category <cat> — Filter by category (AI, Crypto, Data, Trading, Finance, Weather)
  • --limit <n> — Max results (default: 10)

agnic x402 pay

Make an x402 payment request to an API.

agnic x402 pay https://api.example.com/data
# Paying https://api.example.com/data...
# Request complete!
# Status: 200
# Cost: $0.001
# Response:
# { "result": "..." }

Options:

  • --method <METHOD> — HTTP method (default: GET)
  • --body <json> — Request body as JSON string

JSON Output

All commands support --json for machine-readable output:

agnic balance --json
[
  { "network": "base", "balance": "125.50", "address": "0x046906b3..." },
  { "network": "solana", "balance": "0", "address": "N/A" }
]

Configuration

The CLI stores configuration at ~/.agnic/config.json:

{
  "token": "agnic_tok_sk_live_...",
  "email": "[email protected]",
  "walletAddress": "0x..."
}

File permissions are set to 0600 (owner-only read/write).

Custom API URL

agnic --api-url https://custom.api.com balance

Example: Agent Script

#!/bin/bash
# Automated agent workflow
 
# Check balance before operations
BALANCE=$(agnic balance --network base --json | jq -r '.[0].balance')
echo "Current balance: $BALANCE USDC"
 
# Trade some USDC for ETH
agnic trade 5 usdc eth --json
 
# Pay for an API service
agnic x402 pay https://api.example.com/analysis \
  --method POST \
  --body '{"query": "latest market data"}' \
  --json

Next Steps

On this page