Import
Usage
Parameters
GetSingleTokenBalanceArgs
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) |
tokenId | string | Optional. The token ID for ERC721/ERC1155 tokens |
hideUnlistedTokens | boolean | Optional. If true, filters out unverified tokens |
HooksOptions
Parameter | Type | Description |
---|---|---|
retry | boolean | Whether to retry failed requests (default: false ) |
disabled | boolean | Whether to disable the query |
hideCollectibles | boolean | If true, filters out ERC721 and ERC1155 tokens |
Return Type
The hook returns a React Query result object with the following properties:TokenBalance
The returned data contains token balance information:Notes
This hook provides a convenient way to fetch token balances for specific accounts and contracts. Key features:- Native Token Support: Use
ZERO_ADDRESS
for native tokens (ETH, MATIC, etc.) - ERC20 Support: Works with any ERC20 token contract
- NFT Support: Supports ERC721 and ERC1155 tokens with optional
tokenId
- Caching: Uses React Query for efficient caching and background updates
- Error Handling: Provides error states for failed requests
- Loading States: Includes loading indicators for better UX