| name | onchain |
| description | CLI for crypto portfolio tracking, market data, CEX history, and transaction lookups. Use when the user asks about crypto prices, wallet balances, portfolio values, Coinbase/Binance holdings, Polymarket predictions, or transaction details. |
Onchain CLI
CLI for crypto portfolio tracking, market data, and CEX history.
First-Time Setup (Required)
Before using most features, users must configure their API keys:
onchain setup
This interactive wizard helps configure:
- Zerion - Unified EVM + Solana portfolio, balances, and history (recommended — replaces DeBank + Helius for most features)
- Coinbase/Binance - For CEX balances and trade history
- DeBank - For EVM wallet data (fallback if no Zerion key)
- Helius - For Solana wallet data (fallback if no Zerion key)
Without setup: Only onchain price and onchain markets work (using free CoinGecko tier).
Verify setup: Run onchain test to check which providers are configured and working.
Agent note: If a command fails with "not configured" or "API key required", guide the user to run onchain setup first, then onchain test to verify.
Invocation
onchain <command>
Commands
Market Data
onchain price <token>
onchain markets
onchain search <query>
onchain gas
onchain gas --chain polygon
Wallet Data
onchain balance <address>
onchain balance <address> --chain polygon
onchain history <address>
onchain portfolio <address>
Address is required — pass an EVM address (0x...) or a Solana address. There is no default wallet; you must always provide the address explicitly.
Transaction Lookup
onchain tx <hash>
onchain tx <hash> --chain base
onchain tx <explorer-url>
Supports EVM chains (Ethereum, Polygon, Base, Arbitrum, Optimism, BSC, Avalanche, Fantom) and Solana. Accepts raw hashes or explorer URLs (etherscan.io, basescan.org, solscan.io, etc.).
Example Output
Transaction Details
✓ Status: SUCCESS
Hash: 0xd757...5f31
Chain: Base
Block: 41,310,593
Time: Jan 26, 2026, 01:55 PM (4h ago)
Addresses
From: 0xc4e7263dd870a29f1cfe438d1a7db48547b16888
To: 0xab98b760e5ad88521a97c0f87a3f6eef8c42641d
Value & Fee
Value: 0 ETH
Fee: 3.62e-7 ETH
Gas: 96,893 / 249,604 (39%)
Method
ID: 0x6a761202
🔗 https://basescan.org/tx/0xd757...
This output contains all available transaction data. The CLI queries Etherscan/Solscan APIs directly - there is no additional data available from other sources.
CEX Data
onchain coinbase balance
onchain coinbase history
onchain binance balance
onchain binance history
Prediction Markets
onchain polymarket tags
onchain polymarket tags --popular
onchain polymarket trending
onchain polymarket trending --all
onchain polymarket trending --exclude sports,nfl
onchain polymarket trending --include crypto,ai
onchain polymarket search <query>
onchain polymarket view <slug>
onchain polymarket sentiment <topic>
Sentiment analysis: Analyzes prediction markets to determine bullish/bearish expectations:
onchain polymarket sentiment fed
onchain polymarket sentiment bitcoin
onchain polymarket sentiment ai
onchain polymarket sentiment trump
onchain polymarket sentiment fed --json
Tag filtering: Configure default excludes in ~/.config/onchain/config.json5:
{
"polymarket": {
"excludeTags": ["sports", "nfl", "nba", "mlb"],
"includeTags": [] // empty = all non-excluded
}
}
Configuration
onchain setup
onchain config
onchain config set <key> <value>
Wallet Connectivity (WalletConnect)
Connect mobile wallets (MetaMask, Rainbow, etc.) to send transactions:
onchain wallet connect
onchain wallet connect --chain base
onchain wallet status
onchain wallet send <to> <amount>
onchain wallet send <to> <amount> --chain polygon
onchain wallet send <to> <amount> --token 0xUSDC --decimals 6
onchain wallet switch base
onchain wallet disconnect
Global Options
--json - Output as JSON (agent-friendly)
--plain - Disable colors and emoji
--timeout <ms> - Request timeout
Configuration
Config file: ~/.config/onchain/config.json5
Required API Keys
| Feature | API Key | Get Key |
|---|
| Unified wallets (EVM + Solana) | ZERION_API_KEY | Zerion |
| Coinbase CEX | COINBASE_API_KEY + COINBASE_API_SECRET | Coinbase |
| Binance CEX | BINANCE_API_KEY + BINANCE_API_SECRET | Binance |
Fallback API Keys (if no Zerion key)
| Feature | API Key | Get Key |
|---|
| EVM wallets | DEBANK_API_KEY | DeBank |
| Solana wallets | HELIUS_API_KEY | Helius |
Optional API Keys
| Feature | API Key | Notes |
|---|
| Market data | COINGECKO_API_KEY | Free tier works, Pro for higher limits |
| Market fallback | COINMARKETCAP_API_KEY | Alternative market data source |
| EVM tx lookup | ETHERSCAN_API_KEY | For onchain tx on EVM chains |
| Solana tx lookup | SOLSCAN_API_KEY | For onchain tx on Solana |
| Wallet connect | WALLETCONNECT_PROJECT_ID | For onchain wallet commands (Get ID) |
Examples
Get Bitcoin price
onchain price btc
Check wallet balance
onchain balance 0x1234...5678
View portfolio with DeFi positions
onchain portfolio 0x1234...5678
Get trending prediction markets
onchain polymarket trending -n 5
onchain polymarket trending --all
onchain polymarket trending --exclude sports
Lookup a transaction
onchain tx 0xd757e7e4cdb424e22319cbf63bbcfcd4b26c93ebef31d1458ab7d5e986375f31
onchain tx https://basescan.org/tx/0x...
Search for tokens
onchain search pepe
onchain search "shiba inu" -l 5
Check gas prices
onchain gas
onchain gas --chain polygon
onchain gas --json
JSON output for scripts
onchain --json price eth | jq '.priceUsd'
Supported Chains
EVM + Solana (via Zerion — preferred)
Ethereum, BNB Chain, Polygon, Arbitrum, Optimism, Avalanche, Base, zkSync Era, Linea, Scroll, Blast, Mantle, Gnosis, Fantom, Celo, Solana, and more. Single API key covers all chains.
EVM (via DeBank — fallback)
Same EVM chains as above, requires separate DeBank API key.
Solana (via Helius — fallback)
Full Solana mainnet support including SPL tokens and NFTs, requires separate Helius API key.
Agent Integration
This CLI is designed for agent use. Key patterns:
- Always use
--json for programmatic access
- Check exit codes - 0 for success, 1 for error
- Always pass an address - Wallet commands require an explicit address (no default wallet)
- Rate limiting - APIs have rate limits, add delays between rapid calls
Example Agent Usage
VALUE=$(onchain --json portfolio 0x1234...5678 | jq -r '.totalValueUsd')
onchain --json price btc | jq '{price: .priceUsd, change24h: .priceChange24h}'
CHANGE=$(onchain --json markets | jq '.marketCapChange24h')
TX=$(onchain --json tx 0x... --chain base)
echo $TX | jq '{status: .status, from: .from, to: .to, method: .methodId}'
Transaction Lookup Guidance
IMPORTANT: Trust the CLI output. The onchain tx command queries Etherscan (EVM) or Solscan (Solana) APIs directly and returns all available data.
DO NOT:
- Use curl to hit Etherscan/Basescan APIs directly
- Use
cast or other CLI tools as "fallbacks"
- Use WebFetch to scrape block explorer websites
- Assume the CLI is missing data - it returns everything available
DO:
- Use
onchain tx <hash> or onchain tx <explorer-url>
- Use
--json for structured data parsing
- Interpret the output directly to answer user questions
Example interpretation:
onchain tx 0x... --chain base
If output shows Status: SUCCESS, From: 0x..., To: 0x..., Method ID: 0x6a761202 - that's a successful contract interaction. The method ID 0x6a761202 is execTransaction (Gnosis Safe). No additional lookups needed.