Why agents use this
- Pre-flight for every transaction. Before your bot builds a swap, confirm the wallet has enough SOL for rent and fees.
- Free, so use it liberally. No credit debit. Perfect for polling loops and dashboard widgets.
- Two units of measure.
balance_lamportsfor math,balance_solfor display. No conversion errors. - Works on devnet. Testing your bot against devnet? Same endpoint, same shape, just change
network.
Use cases
- Agent “can I afford this?” guard. Before submitting any paid gateway call or on-chain tx, check the wallet has minimum SOL. Skip if not.
- Wallet dashboard live widget. Poll every 5 seconds for a Vue/React balance display.
- Health check / uptime ping. Free endpoint = free ping. Alerts on non-200 from your monitoring stack.
- Multi-wallet portfolio. Fan out balance checks across a family of wallets (treasury, hot, cold) in parallel.
- Referral leaderboard. Show current SOL balance next to each referred wallet in your incentives dashboard.
Recipe: minimum-balance guard for a trading bot
balance-guard.ts