Skip to content
datastore.sh

Solana Wallet Balance History: Rebuild Any Balance at Any Slot

Three ways to get a Solana wallet's past SOL or token balance, how Solana actually records balances, and SQL that rebuilds the balance of any wallet at any slot from balance-change data, including the same-slot and failed-transaction cases most tools skip.

Data Platform12 min read

Solana wallet balance history is the record of a wallet's SOL and token balances over time: what it held at a given slot, how that changed, and which transaction changed it. Solana itself only serves current balances. Every past balance has to be looked up in an index someone built, or rebuilt from the balance changes recorded in each transaction.

Where your answer comes from changes what you can ask. A point-in-time API answers one wallet, one token and one moment per request. A change log answers any wallet at any slot, gives you a daily series, or lists every holder of a token. It also leaves you with a few edge cases to handle yourself.

This guide covers the three ways to get historical balances, how Solana records a balance, and what the Wallet SOL Balance Changes and Token Balance Changes datasets contain. It then gives SQL that rebuilds a balance at any slot, including the two cases most tools ignore: several changes in one slot, and fees from failed transactions.

Three Ways to Get a Historical Balance

Three shapes of Solana wallet balance history data. A point-in-time API returns one wallet, one token and one slot per call. A snapshot table stores one balance per address per day, or only the latest. A change log stores one row per balance change with the balance before and after, so the balance at any slot is the last change at or before it.

ShapeExamplesAnswers wellLeaves to you
Point-in-time APIAlchemy getTokenAccountsByOwnerAtSlot; Helius balance-at"What did this wallet hold at slot X?" for a few walletsOne request per wallet or per token; a time series means many calls
SnapshotsDaily or latest balance tablesEnd-of-day balances and current holdersNothing between snapshots; intraday moves are lost
Change logAllium solana.assets.balances; Wallet SOL and Token Balance ChangesAny wallet at any slot, series, holder listsThe rebuild logic in this guide

The point-in-time APIs differ in detail. Alchemy's method returns a wallet's token accounts at a past slot from "a prebuilt historical index", up to 10,000 accounts per page. SPL Token and Token-2022 need separate calls, which you then combine (Alchemy, July 2026). Helius's GET /v1/wallet/{wallet}/balance-at takes one mint and exactly one of a slot, a Unix time or a datetime, and costs 100 credits per request (Helius docs).

Snapshot tables are easy to misread. Dune's documentation page titled "Solana daily balances" describes solana_utils.latest_balances, which holds "current SOL and SPL token balances for every address", not a daily history (Dune docs). Allium keeps both kinds: a change table where "each row is the balance of one account for one token after a transaction changed it", plus daily and latest tables (Allium docs).

For one wallet at one moment, an API call is quicker. For anything across many wallets, or across time, a change log is the right shape, because one dataset answers every slot.

How Solana Records a Balance

Every Solana transaction carries metadata listing the balance of each account it touched, before and after the transaction. SOL balances are in lamports (1 SOL = 1,000,000,000 lamports). Token balances are listed per token account, with the token account's owner, the mint and the token's decimals. The balance datasets are built directly from this metadata in raw Solana blocks, so they read the balances the chain recorded rather than recomputing them from instructions.

Three properties of Solana's account model shape every query below:

  1. Tokens live in token accounts, not in wallets. A wallet holds a token through a token account it owns, usually its associated token account. A wallet can own more than one account for the same mint, so a wallet's token balance is the sum across its token accounts.
  2. Only changes are recorded. If a balance does not change in a transaction, no row is written. The balance at slot X is the balance after the last change at or before X, carried forward.
  3. Ownership can move. A token account's owner can be reassigned, so the owner on the latest row is the one that counts.

What the Balance Change Datasets Contain

Both datasets have one row per account whose balance changed in a successful transaction.

Wallet SOL Balance Changes (BalanceChanges)Token Balance Changes (TokenBalanceChanges)
ts, slot, sigts, slot, sig
accounttoken_account, owner, mint, decimals
is_fee_payer
pre_lamports, post_lamportspre_amount, post_amount (raw units)
change_lamports, change_solchange (raw units), change_ui (whole tokens)

Because every row has both the before and after balance, you never need to add up changes from the start of time to get a balance. The last post_lamports or post_amount at or before your slot is the balance. That avoids the most common way rebuilt balances go wrong, where one missing row throws off every running total after it.

Querying Wallet Balance History

The queries use DuckDB against the delivered Parquet layout. Replace 461820000 with the slot you want.

SOL balance of a wallet at a slot

sql
WITH rows AS (
  SELECT *
  FROM read_parquet('solana/wallet/wallet_sol_balance_changes/schema=v1.0/balance_changes/**/*.parquet')
  WHERE account = '<wallet address>'
    AND slot <= 461820000
),
slot_end AS (
  -- within one slot, keep the change no later change continues from
  SELECT * FROM rows r
  WHERE NOT EXISTS (
    SELECT 1 FROM rows n
    WHERE n.slot = r.slot AND n.sig <> r.sig
      AND n.pre_lamports = r.post_lamports)
),
last_change AS (
  SELECT slot, post_lamports FROM slot_end ORDER BY slot DESC LIMIT 1
),
failed_fees AS (
  SELECT coalesce(sum(fee_paid_lamports), 0) AS lamports
  FROM read_parquet('solana/network/failed_transactions_errors/schema=v1.0/failed_transactions/**/*.parquet')
  WHERE fee_payer = '<wallet address>'
    AND slot >  (SELECT slot FROM last_change)
    AND slot <= 461820000
)
SELECT l.slot                               AS last_change_slot,
       (l.post_lamports - f.lamports) / 1e9 AS sol_balance
FROM last_change l, failed_fees f;

Two parts of this query are easy to miss:

Rebuilding a Solana balance at a slot from a change log. Three changes to the same account land in one slot; their before and after balances link into a chain, and the end of the chain is the balance after that slot. Later, a failed transaction charges a fee that has no balance-change row, so the rebuilt balance subtracts it from the Failed Transactions dataset.

  • Several changes in one slot. A busy wallet can change balance in several transactions in the same slot, and the rows carry no position within the slot. Each change starts from the balance the previous one left, so the rows link into a chain: one row's pre_lamports equals another's post_lamports. The end of the chain is the one no other row continues from, and that is the balance after the slot. The free sample contains exactly this case.
  • Fees from failed transactions. The balance datasets only record successful transactions, but a failed transaction still charges its fee to the fee payer. The Failed Transactions & Errors dataset records each one with fee_payer and fee_paid_lamports, so the query subtracts fees charged after the last recorded change. A failed transaction in the same slot as the last change cannot be placed before or after it, so for exact accounting, check that slot by hand.

A wallet's token balance at a slot

sql
WITH rows AS (
  SELECT *
  FROM read_parquet('solana/token/token_balance_changes/schema=v1.0/token_balance_changes/**/*.parquet')
  WHERE owner = '<wallet address>'
    AND mint  = '<mint address>'
    AND slot <= 461820000
),
slot_end AS (
  SELECT * FROM rows r
  WHERE NOT EXISTS (
    SELECT 1 FROM rows n
    WHERE n.token_account = r.token_account AND n.slot = r.slot AND n.sig <> r.sig
      AND n.pre_amount = r.post_amount)
),
per_account AS (
  SELECT token_account,
         arg_max(post_amount, slot) AS amount,
         any_value(decimals)        AS decimals
  FROM slot_end
  GROUP BY token_account
)
SELECT sum(amount) / 10 ^ any_value(decimals) AS token_balance,
       count(*)                              AS token_accounts
FROM per_account;

The last step sums across token accounts, because a wallet can hold one mint in more than one account. Token fees work differently from SOL fees: a failed transaction never moves tokens, so no adjustment is needed here.

End-of-day SOL balances for a wallet

sql
WITH rows AS (
  SELECT *
  FROM read_parquet('solana/wallet/wallet_sol_balance_changes/schema=v1.0/balance_changes/**/*.parquet')
  WHERE account = '<wallet address>'
),
slot_end AS (
  SELECT * FROM rows r
  WHERE NOT EXISTS (
    SELECT 1 FROM rows n
    WHERE n.slot = r.slot AND n.sig <> r.sig
      AND n.pre_lamports = r.post_lamports)
)
SELECT CAST(timezone('UTC', ts) AS DATE)   AS day_utc,
       arg_max(post_lamports, slot) / 1e9  AS end_of_day_sol,
       count(*)                            AS slots_with_changes
FROM slot_end
GROUP BY day_utc
ORDER BY day_utc;

Days with no change have no row. The balance on those days is the previous day's value, so fill it forward when you chart the series. The timezone('UTC', …) call pins days to UTC, so the result does not shift with your session's time zone. This series ignores failed-transaction fees. For a wallet that sends many failing transactions, subtract them per day as in the first query.

Every holder of a token at a slot

sql
WITH rows AS (
  SELECT *
  FROM read_parquet('solana/token/token_balance_changes/schema=v1.0/token_balance_changes/**/*.parquet')
  WHERE mint = '<mint address>'
    AND slot <= 461820000
),
slot_end AS (
  SELECT * FROM rows r
  WHERE NOT EXISTS (
    SELECT 1 FROM rows n
    WHERE n.token_account = r.token_account AND n.slot = r.slot AND n.sig <> r.sig
      AND n.pre_amount = r.post_amount)
),
per_account AS (
  SELECT token_account,
         arg_max(owner, slot)       AS owner,
         arg_max(post_amount, slot) AS amount,
         any_value(decimals)        AS decimals
  FROM slot_end
  GROUP BY token_account
)
SELECT owner, sum(amount) / 10 ^ any_value(decimals) AS balance
FROM per_account
GROUP BY owner
HAVING sum(amount) > 0
ORDER BY balance DESC
LIMIT 20;

This builds a holder list at any slot, not only at the end of a day. It takes each token account's latest owner, as described above. It is complete only if your data covers the token from its first mint: a holder whose last change came before your data starts will not appear. For Pump.fun tokens, Token Holder Distribution publishes daily holder snapshots already rebuilt from launch, within the window its dataset page states.

Pitfalls Checklist

  1. Use the after balance, not a running sum. post_lamports and post_amount are absolute, so one missing row cannot throw off the rest.
  2. Resolve same-slot changes by following the before-and-after chain. Ordering by sig or ts does not give the order within a slot.
  3. Subtract failed-transaction fees for SOL balances. Failed transactions change the fee payer's balance without a balance-change row.
  4. Sum token accounts per owner. A wallet can hold one mint in more than one token account.
  5. Take the latest owner of each token account. Ownership can be reassigned.
  6. Divide by decimals only at the end. Raw u64 amounts are exact; floating-point whole-token values are not.
  7. Start your history early enough. An account that last changed before your data starts is invisible, not empty.
  8. Fill forward between changes when you build a time series.

If you need the transactions behind each change as well, our guide to downloading Solana transaction history covers the transaction-level data. To compare vendors more broadly, see how to choose a historical Solana data provider. To turn balance moves into trading profit, read Solana wallet PnL data. For a side-by-side of Helius, Alchemy, Dune, Allium and datastore.sh, see Solana historical balance APIs compared.

Frequently Asked Questions

How do I see a Solana wallet's balance history?

A block explorer shows one wallet's recent changes. For an exact balance at a past slot, use a point-in-time API such as Alchemy's or Helius's for a few wallets, or a balance-change dataset for many wallets, where the balance at a slot is the last recorded balance at or before it.

Can I get a Solana wallet's balance at a specific slot?

Yes. With a change log, take the last row for the account at or before the slot and read its after balance. Resolve several changes in the same slot by following the before-and-after chain. For SOL, subtract fees from any failed transactions the wallet paid for after that change.

Why does my rebuilt SOL balance differ from the explorer?

The usual causes are fees from failed transactions, which still charge the fee payer but change no other balance, and several changes in one slot read in the wrong order. A running sum that misses a single row is the third. Using after balances and the Failed Transactions dataset fixes all three.

What is the difference between a token account and a wallet?

A wallet is the address that signs transactions and holds SOL. Tokens sit in separate token accounts that the wallet owns, one or more per mint. Historical token balances are recorded per token account, so you sum them by owner to get the wallet's balance.

Is there an alternative to getTokenAccountsByOwnerAtSlot?

For one wallet, Alchemy's method or Helius's balance-at endpoint is the simplest route. For many wallets, or a full time series, a balance-change dataset avoids one request per wallet or per token: one query returns every wallet's balance at any slot.

Where can I download Solana balance history data?

datastore.sh delivers Wallet SOL Balance Changes and Token Balance Changes as Parquet, with the before and after balance on every row, built from raw Solana blocks. Free samples of each table are on the dataset pages, and the queries in this guide run on them as written.

Sources