Skip to main content

addTokenBalance(options)

This allows for tracking token balances. options has the following structure:
The data requests here are:
  • account: the set of accounts to track. Leave undefined to subscribe to balance updates of all accounts across the network.
  • preProgramId: pubkeys of the Token program that owned the account prior to execution.
  • postProgramId: pubkeys of the Token program that owns the account after execution.
  • preMint: pubkeys of the token’s mint prior to execution.
  • postMint: pubkeys of the token’s mint after execution.
  • preOwner: pubkeys of the token balance’s owner prior to execution.
  • postOwner: pubkeys of the token balance’s owner after execution.
All account/pubkeys should be base58-encoded strings. Retrieved items may contain pre-state, post-state, or both: pre* fields describe the value before the transaction and post* fields describe it after the transaction (see TokenBalance field selection). Related data retrieval flags:
  • transaction = true: retrieve the transaction that gave rise to the balance update
  • transactionInstructions = true: retrieve all instructions executed by the parent transaction
The related data will be added to the appropriate iterables within the block data. You can also call augmentBlock() from @subsquid/solana-objects on the block data to populate the convenience reference fields like tokenBalance.transaction. Selection of the exact fields to be retrieved for each token balance item and the related data is done with the setFields() method documented on the Field selection page.