
Check Wallet Balances Across 4 Chains with Zero Dependencies — chain_balance.py
TL;DR: A single-file Python CLI tool that checks native and token balances across Solana, Ethereum, BSC, and Polygon using public RPC endpoints. No pip install required. Just Python 3 and a wallet address. GitHub: https://github.com/neuralmint/multichain-balance-cli Why Another...
Check Wallet Balances Across 4 Chains with Zero Dependencies — chain_balance.py
TL;DR: A single-file Python CLI tool that checks native and token balances across Solana, Ethereum, BSC, and Polygon using public RPC endpoints. No pip install required. Just Python 3 and a wallet address.
GitHub: https://github.com/neuralmint/multichain-balance-cli
Why Another Balance Checker?
Most multi-chain balance checkers fall into two categories:
Web dashboards — nice UI but no CLI, no scripting, no automation
Heavy SDKs — ethers.js, web3.py, solana-py — each requires its own install, its own API keys, its own learning curve
I wanted something I could run on any server with Python 3, pipe into jq, drop into a cron job, and never worry about dependency rot. The result is a single 278-line Python file that works out of the box.
What It Does
# Check all 4 chains at once python3 chain_balance.py --address 0x742d35Cc6634C0532925a3b844Bc1dC3E92bBbb7
# Just Solana python3 chain_balance.py --address 4TGyiYBjaYhFFPNYyCoJjf16ctUsWVBiMR1FXQxEfhWi --chains solana
# JSON mode for jq/shell pipelines python3 chain_balance.py --address 0x... --chains eth,polygon --json | jq '.results[].native'
# Silent mode for cron jobs python3 chain_balance.py --address 0x... --quiet --json > report.json
Supported Chains
Chain Native Token RPC Endpoint
Solana SOL api.mainnet-beta.solana.com
Ethereum ETH ethereum-rpc.publicnode.com
BSC BNB bsc-dataseed1.binance.org
Polygon MATIC polygon-rpc.com
Token Coverage
For each EVM chain, it checks the top 5 tokens by market cap:
Ethereum: USDT, USDC, LINK, UNI, DAI
BSC: USDT, USDC, BUSD, WBNB, CAKE
Polygon: USDT, USDC, WMATIC, LINK, WETH
Solana: All SPL tokens via getTokenAccountsByOwner (auto-discovers any token you hold)
How It Works
Pure JSON-RPC 2.0 calls over HTTPS using Python's stdlib urllib. No HTTP library, no Web3 SDK, no Solana SDK:
def rpc_call(url, method, params): payload = json.dumps({ "jsonrpc": "2.0", "id": 1, "method": method, "params": params, }).encode() req = urllib.request.Request(url, data=payload, headers={"Content-Type": "application/json"}) with urllib.request.urlopen(req, timeout=15) as resp: return json.loads(resp.read().decode()).get("result")
For Solana, it uses getTokenAccountsByOwner with the Token program ID to discover all SPL tokens in the wallet — not just a hardcoded list.
Example Output
════════════════════════════════════════════════════════ Multi-Chain Balance Report Address: 0x742d35Cc6634C0532925a3b844Bc1dC3E92bBbb7 ════════════════════════════════════════════════════════
┌── SOLANA ──────────────────────────────── │ Native: 0.000000 SOL │ (no token balances found) └─────────────────────────────────────────────
┌── ETH ──────────────────────────────────── │ Native: 0.000000 ETH └─────────────────────────────────────────────
Use Cases
Cron job monitoring: Check your wallet daily, email if balance drops below threshold
Portfolio dashboard: Pipe --json into a shell script that builds a dashboard
Swap pre-flight: Check you have enough gas tokens before sending a transaction
CI/CD health check: Verify a faucet wallet still has funds
Tips
If this tool saves you time or money, tips are appreciated:
SOL: 4TGyiYBjaYhFFPNYyCoJjf16ctUsWVBiMR1FXQxEfhWi
ETH/ERC-20: 0xe07f177E0725c11EEc8BeA34C5b5193CaF2a1A6a
What's Next
This is part of the neuralmint CLI Tools series. Previous tools in the series:
wallet_tracker.py — transaction history tracker
token_info.py — token metadata lookup
crypto_sentiment.py — sentiment analysis from social feeds
crypto_news.py — crypto news aggregator
All tools are single-file, MIT-licensed, and zero-dependency.
Built with Python 3 stdlib. No npm, no pip, no bloat.
📰Originally published at dev.to
Staff Writer