CLI Tool
Command-line interface for Agnic Wallet operations and x402 transactions
CLI Tool
The agnic CLI lets you manage your Agnic Wallet and authorize transactions directly from the terminal. It's designed for AI agents, scripts, and developers who prefer the command line.
Installation
npx agnic@latest --helpOr install globally:
npm install -g agnicAuthentication
The CLI supports three authentication methods (in priority order):
--tokenflag — passed directly on each commandAGNIC_TOKENenv var — set in your shell environment- Stored token — saved locally via
agnic auth login
Login via Browser (OAuth2)
agnic auth login
# Opens your browser → sign in → set spending limits → done!
# Output: Authenticated!
# Email: [email protected]
# Wallet: 0x046906b3...The CLI opens your browser to Agnic where you sign in with your account and set spending limits. Once approved, tokens are saved locally with 90-day expiry. Tokens auto-refresh when expired.
Using Environment Variable
export AGNIC_TOKEN=agnic_at_abc123...
agnic balanceUsing Token Flag
agnic balance --token agnic_at_abc123...Logout
agnic auth logoutCommands
agnic status
Check authentication and wallet status.
agnic status
# User ID: did:privy:abc123
# Email: [email protected]
# Wallet: 0x046906b3...
# Token expires: 89 daysagnic 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 USDCagnic address
Show your wallet address.
agnic address
# 0x046906b3cd9d73bf85eb01d795d333b364b75842agnic x402 search
Search for X402-enabled APIs.
agnic x402 search "sentiment analysis"
# Found 3 API(s):
# 1. Sentiment Pro
# Real-time sentiment analysis
# Price: $0.001 /requestOptions:
--category <cat>— Filter by category (AI, Crypto, Data, Finance, Weather)--limit <n>— Max results (default: 10)
agnic x402 pay
Make an x402 request to an API.
agnic x402 pay https://api.example.com/data
# Requesting 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:
{
"accessToken": "agnic_at_abc123...",
"refreshToken": "agnic_rt_xyz789...",
"expiresAt": 1756000000000,
"userId": "did:privy:abc123",
"email": "[email protected]",
"walletAddress": "0x..."
}File permissions are set to 0600 (owner-only read/write).
Token Auto-Refresh: When your access token expires, the CLI automatically refreshes it using the stored refresh token. No manual re-authentication needed unless the refresh token also expires (90 days).
Custom API URL
agnic --api-url https://custom.api.com balanceAgent Identity
Check your agent's on-chain ERC-8004 identity, trust score, and delegation info.
agnic agent-identity [--json]Example output:
Agent Identity
Agent ID: #396
Chain ID: 84532
Wallet: 0xe38b20d6eb4dbd04b7f13fa8f9b6352d3824a0e1
Trust Score: 26
Status: active
Delegation: active (ID: 4a4ce438-...)
Agent Card: https://kya.agnic.ai/.well-known/agent-cards/396.jsonAgent Email
Manage your agent's dedicated email address (agent-{id}@agent.agnic.ai).
# Show email address
agnic email address [--json]
# Create email alias
agnic email setup [--display-name <name>] [--json]
# Check inbox
agnic email inbox [--limit <n>] [--json]
# Send email
agnic email send --to <address> --subject <subject> --body <body> [--json]
# Reply to a message
agnic email reply --message-id <id> --body <body> [--json]Example:
agnic email setup --display-name "Research Agent"
agnic email send --to [email protected] --subject "Results" --body "Analysis complete"
agnic email inbox --jsonExample: 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"
# Access an x402 API service
agnic x402 pay https://api.example.com/analysis \
--method POST \
--body '{"query": "latest market data"}' \
--json