Reconcile an SPL token balance across a wallet’s accounts

A wallet can hold the same Solana token in more than one token account. Looking up only its associated token account can leave part of the balance out of a reconciliation report.

Find the accounts for one mint

Replace both placeholders with base58 public addresses for the same cluster. The first is the wallet authority. The mint identifies the asset, even when several unrelated tokens use the same trading symbol. POST this body to the cluster’s HTTP RPC.

{"jsonrpc":"2.0","id":1,"method":"getTokenAccountsByOwner","params":["WALLET_PUBLIC_KEY",{"mint":"TOKEN_MINT_PUBLIC_KEY"},{"commitment":"finalized","encoding":"jsonParsed"}]}

For each entry under result.value, keep its pubkey and read account.data.parsed.info.tokenAmount. A successful empty array means the query found no matching accounts at that context. If decoding fails, preserve the error or undecoded row so the report cannot mistake it for a zero balance.

Sum exact units before formatting

Suppose two accounts for a conventional six-decimal mint return amount strings 1250000 and 40001. Parse each as an arbitrary-precision integer and sum to 1290001 base units. Apply the six decimal places once to display 1.290001 tokens. Keep the original total, mint, scale and context.slot in the record so another worker can reproduce the arithmetic.

Investigate a disputed row

Read getTokenAccountBalance for the individual token account’s pubkey. Compare the context slots when a later read differs. A transfer between reads may explain a discrepancy. The reconciled raw amount measures holdings. Frozen accounts and token extensions can affect the amount available for transfer or the displayed value.

Solana documentation