GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `stellar token balance` command by fnando · Pull Request #2651 · stellar/stellar-cli

Conversation

@fnando

@fnando fnando commented Jul 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

What

Add a stellar token balance command that reads the token balance of an account or contract. The token can be specified as a contract id or alias, native, or a classic asset as CODE:ISSUER. By default the balance is returned in the token's raw smallest unit (stroops for a Stellar Asset Contract); --decimal formats it using the token's decimals. Output is available as text (default) or JSON via --output.

$ $stellar token balance --id native --account fnando --output=json
{"balance":"100000000000"}

$ $stellar token balance --id native --account fnando
100000000000

$ $stellar token balance --id usdc --account fnando --network testnet
2000000

$ $stellar token balance --id USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5 --account fnando --network testnet
2000000

$ $stellar token balance --id USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5 --account fnando --network testnet --decimal
0.2

$ http https://horizon-testnet.stellar.org/accounts/$($stellar keys address fnando) | jq '.balances | first | {asset_code, asset_issuer, balance}'
{
  "asset_code": "USDC",
  "asset_issuer": "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
  "balance": "0.2000000"
}

Why

Reading a token balance previously required a manual stellar contract invoke ... -- balance call and hand-decoding the result. This adds a first-class, read-only command that resolves the token (including classic assets and native) and returns a clean value, with token-aware errors when a Stellar Asset Contract isn't deployed yet.

Known limitations

N/A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings July 20, 2026 17:46
@github-project-automation github-project-automation Bot added this to DevX Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Jul 20, 2026
Copilot started reviewing on behalf of fnando July 20, 2026 17:47
View session
@fnando fnando self-assigned this Jul 20, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Jul 20, 2026
Copilot AI reviewed Jul 20, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class token balance queries with raw/decimal and text/JSON output.

Changes:

  • Adds stellar token balance and token resolution/error handling.
  • Extends JSON errors with machine-readable types.
  • Adds integration tests and help documentation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
FULL_HELP_DOCS.md Documents the balance command.
cmd/soroban-cli/src/output.rs Adds typed JSON errors.
cmd/soroban-cli/src/commands/token/transfer.rs Reuses shared token errors.
cmd/soroban-cli/src/commands/token/mod.rs Registers the balance subcommand.
cmd/soroban-cli/src/commands/token/balance.rs Implements balance queries.
cmd/soroban-cli/src/commands/token/args.rs Adds shared deployment errors.
cmd/soroban-cli/src/cli.rs Routes typed JSON failures.
cmd/crates/soroban-test/tests/it/integration/token/mod.rs Registers balance tests.
cmd/crates/soroban-test/tests/it/integration/token/balance.rs Tests balance behavior and errors.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cmd/soroban-cli/src/commands/token/args.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cmd/soroban-cli/src/commands/token/balance.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fnando
fnando force-pushed the token-balance branch from b91338b to 37cd0cf Compare July 20, 2026 17:53
@fnando
Add token balance command with optional decimal output.
e98e04f
@fnando
fnando force-pushed the token-balance branch from 37cd0cf to e98e04f Compare July 20, 2026 17:58
@fnando
fnando requested review from aristidesstaffieri and mootz12 July 20, 2026 18:01
@fnando
fnando enabled auto-merge (squash) July 20, 2026 20:31
leighmcculloch
leighmcculloch approved these changes Jul 21, 2026
View reviewed changes

@leighmcculloch leighmcculloch left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions, but defer to you and looks good otherwise. The UX looks good with defaulting to raw values and offering decimal encoding if specified. I like how the flag is named --decimal which aligns with the decimals function name.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cmd/soroban-cli/src/commands/token/args.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cmd/soroban-cli/src/commands/token/balance.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fnando
Treat native as a SAC and centralize decimal formatting.
54005e9
@fnando fnando mentioned this pull request Jul 21, 2026
Centralize asset/token resolution behind a single resolver #2652
Closed
@fnando
fnando merged commit f3776b6 into main Jul 21, 2026
226 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@fnando
fnando deleted the token-balance branch July 21, 2026 16:17
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in DevX Jul 21, 2026
@fnando fnando mentioned this pull request Jul 22, 2026
Centralize asset/token resolution behind a single resolver #2654
Merged
@fnando fnando mentioned this pull request Oct 7, 2026
stellar token: typed SEP-41 + SAC client #2620
Closed
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@leighmcculloch leighmcculloch leighmcculloch approved these changes
@aristidesstaffieri aristidesstaffieri Awaiting requested review from aristidesstaffieri
@mootz12 mootz12 Awaiting requested review from mootz12

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@fnando fnando

Labels

None yet

Projects

DevX
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@fnando @leighmcculloch
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.