Hooks
useGetSingleTokenBalanceSummary
Hook for fetching a specific token balance for an account on a chain
Import
Usage
Return Type: UseQueryResult<TokenBalance>
The hook returns all properties from React Query’s UseQueryResult
with token balance data. Here’s the detailed structure:
Properties
data
TokenBalance | undefined
Token balance object containing:
contractType
: The type of contract (ERC20, ERC721, ERC1155)contractAddress
: The token contract addressaccountAddress
: The address whose balance was queriedbalance
: The balance amount in the token’s base unitschainId
: The chain ID where the balance was fetched fromblockHash
: Hash of the block containing the balanceblockNumber
: Number of the block containing the balancetokenID
: Optional token ID for NFTsuniqueCollectibles
: Number of unique collectiblesisSummary
: Whether this is a summary balancecontractInfo
: Optional contract informationtokenMetadata
: Optional token metadata
isLoading
boolean
Loading state for the data fetch.
isError
boolean
Error state indicating if the query failed.
error
Error | null
Any error that occurred during data fetching.
Parameters
The hook accepts two parameters:
args: GetSingleTokenBalanceSummaryArgs
Parameter | Type | Description |
---|---|---|
chainId | number | The chain ID to fetch the balance from |
accountAddress | string | The address to fetch the balance for |
contractAddress | string | The token contract address (use ZERO_ADDRESS for native tokens) |
options: BalanceHookOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
hideCollectibles | boolean | (Optional) If true, filters out ERC721 and ERC1155 tokens |
Was this page helpful?