Hooks
useGetNativeTokenBalance
Hook for fetching native token balances across multiple chains
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
Array of token balance objects containing:
chainId
: The chain ID where the balance was fetched fromaccountAddress
: The address whose balance was queriedcontractAddress
: The address of the native token (typically zero address)balance
: The balance amount in the token’s base unitscontractType
: The type of contract (e.g., ERC20, ERC721, ERC1155)contractInfo
: Additional contract informationtokenMetadata
: Metadata about the tokenblockHash
: The hash of the block in which the balance was recordedblockNumber
: The number of the block in which the balance was recordeduniqueCollectibles
: The number of unique collectiblesisSummary
: Whether the balance is a summarytokenID
: The ID of the token (for ERC721 and ERC1155 tokens)
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: GetNativeTokenBalanceArgs
Parameter | Type | Description |
---|---|---|
accountAddress | string | The address to fetch balances for |
chainIds | number[] | Array of chain IDs to fetch balances from |
networks | string[] | Array of network names to fetch balances from |
options: HooksOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
Was this page helpful?