Skip to main content

BSC Transaction Balance Tracker API: Balance Changes With a Reason Code

The TransactionBalances cube under EVM(network: bsc) writes one row for every balance that a transaction changes: the address, the currency, the balance before and after, the USD value, and for BNB a reason code that says why it moved. A transfer, a gas charge, a gas refund, a fee credit to the block producer and a self-destruct each carry their own code, so one filter separates them without decoding calls. The same rows serve as a live stream and as a query over the recent realtime window; the cube has no archive dataset, so keep what you need by recording the stream. Every example on the tracker pages runs in the IDE on a free account.

The reason codes that occur on BNB Chain

Native BNB rows carry one of these in live data. The rest of the schema, listed further down, belongs to other chains' history and returns nothing here.

CodeNameWhat it marksPage
10BalanceChangeTransferBNB moved by a transaction or an internal callTransaction tracker
6BalanceDecreaseGasBuyGas limit charged to the sender before executionGas tracker
7BalanceIncreaseGasReturnUnused gas refunded after executionGas tracker
5BalanceIncreaseRewardTransactionFeeFee for used gas credited to the fee holder, then deposited to the ValidatorSet contract per blockMEV tracker, Miner tracker
12, 13BalanceIncreaseSelfdestruct, BalanceDecreaseSelfdestructRecipient and contract of a selfdestructSelf-destruct tracker
0BalanceChangeUnspecifiedEverything without a more specific reason, and every token rowTransaction tracker

Codes 1 and 2, the mining rewards, never appear because BNB Chain has validators, not miners; code 3, consensus-layer withdrawals, never appears because withdrawals are not transactions; code 14 has no live occurrences. The miner tracker shows the count query that proves it and what block producers earn instead.

The tracker pages

One row, three shapes

The fields a row carries depend on the currency.

  • BNB: BalanceChangeReasonCode, PreBalance, PostBalance, PostBalanceInUSD.
  • BEP-20 tokens: PostBalance, PostBalanceInUSD, TotalSupply, TotalSupplyInUSD; no pre-balance and no reason code.
  • NFTs: PostBalance and TokenOwnership; no USD values.

The smallest useful query

The newest balance changes of one address, any currency, which is the shape most of the tracker pages build on.

{
EVM(network: bsc) {
TransactionBalances(
limit: { count: 10 }
orderBy: { descending: Block_Time }
where: { TokenBalance: { Address: { is: "0x238a358808379702088667322f80ac48bad5e6c4" } } }
) {
Block {
Time
}
TokenBalance {
BalanceChangeReasonCode
PreBalance
PostBalance
PostBalanceInUSD
Currency {
Symbol
Native
}
}
Transaction {
Hash
}
}
}
}

Change query to subscription and drop limit and orderBy to follow the address live. Kafka carries the same rows on the bsc.tokens.proto topic; see the Kafka streams hub.

The full code list

Defined for every EVM chain the cube serves; only the codes in the first table occur on BNB Chain.

CodeReasonDescription
0BalanceChangeUnspecifiedNo specific reason recorded
1BalanceIncreaseRewardMineUncleUncle block reward (proof-of-work chains)
2BalanceIncreaseRewardMineBlockBlock mining reward (proof-of-work chains)
3BalanceIncreaseWithdrawalConsensus-layer validator withdrawal
4BalanceIncreaseGenesisBalanceBalance allocated at genesis
5BalanceIncreaseRewardTransactionFeeFee for used gas credited to the block producer
6BalanceDecreaseGasBuyGas limit charged before execution
7BalanceIncreaseGasReturnUnused gas refunded after execution
8BalanceIncreaseDaoContractDAO refund contract credit (Ethereum, 2016)
9BalanceDecreaseDaoAccountDAO account debit (Ethereum, 2016)
10BalanceChangeTransferValue moved by a call
11BalanceChangeTouchAccountZero-value transfer that creates an account
12BalanceIncreaseSelfdestructRecipient of a self-destructed contract's balance
13BalanceDecreaseSelfdestructContract emptied by self-destruct
14BalanceDecreaseSelfdestructBurnValue sent to an account already destroyed in the same transaction
15BalanceChangeRevertBalance restored after a failed call

Frequently Asked Questions

What is the BSC transaction balance tracker?

A cube that records every balance a transaction changes on BNB Chain, with the balance before and after and, for BNB, a reason code. It answers who paid, who received, how much gas was charged and refunded, and where fees went, in one query or stream.

Which reason codes actually occur on BNB Chain?

0, 5, 6, 7, 10, 12 and 13. Mining codes 1 and 2 and withdrawal code 3 never appear, and code 14 has no live occurrences.

Do token balances carry a reason code?

No. Reason codes are for BNB only. BEP-20 rows carry the post balance, its USD value and the token's total supply; NFT rows carry the post balance and ownership.

How far back does the balance tracker go?

The recent realtime window only; there is no archive dataset for this cube. Stream the rows you need, over WebSocket or the Kafka topic, and store them.

How does it differ from the Balances cube?

Balances gives the current balance of an address whether or not it transacted recently. TransactionBalances gives the history of changes with reasons, but only for addresses that transacted inside the window.

Build with Bitquery

Ready to run this in production?

Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.