Skip to content

feat: implement balance command for ERC20 token balances#36

Merged
broody merged 3 commits intomainfrom
feat/balance-command
Feb 14, 2026
Merged

feat: implement balance command for ERC20 token balances#36
broody merged 3 commits intomainfrom
feat/balance-command

Conversation

@broody
Copy link
Collaborator

@broody broody commented Feb 14, 2026

Summary

  • Add controller balance [symbol] command that queries ERC20 token balances for the active session account
  • Built-in support for 7 mainnet tokens: ETH, STRK, USDC, USD.e, LORDS, SURVIVOR, WBTC
  • Custom tokens via controller config set token.<symbol> <address> (extends config with tokens map)
  • All balance queries fire concurrently via tokio::spawn + futures::join_all
  • 30s file-based cache to avoid redundant RPC calls
  • Human-readable output (0.001 ETH) by default, structured JSON with --json
  • Zero balances hidden when querying all tokens

Usage

# Query all non-zero balances
controller balance --chain-id SN_MAIN

# Query specific token
controller balance eth --chain-id SN_MAIN

# Add custom token
controller config set token.custom 0x1234...

# JSON output
controller balance --json --chain-id SN_MAIN

Test plan

  • controller balance --chain-id SN_MAIN returns non-zero balances
  • controller balance eth --chain-id SN_MAIN returns single token
  • controller balance --json --chain-id SN_MAIN returns structured JSON
  • Repeated calls within 30s hit cache (instant response)
  • controller config set token.custom <addr> then controller balance custom works
  • Unknown token symbol returns helpful error

🤖 Generated with Claude Code

broody and others added 3 commits February 13, 2026 22:10
Query ERC20 token balances for the active session account with built-in
support for ETH, STRK, USDC, USD.e, LORDS, SRVR, and WBTC on mainnet.
Custom tokens can be added via `controller config set token.<symbol> <address>`.
Queries are fired concurrently and cached for 30s to avoid redundant RPC calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use &Path instead of &PathBuf in cache function signatures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@broody broody merged commit 9527c3f into main Feb 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments