useGetAccountNativeBalance
Use this hook to fetch the native token balance for an address on the target network.
Usage
const { balance, loading, error, nativeTokenSymbol } = useGetAccountNativeBalance(address);
This example retrieves the native token balance of the address.
Parameters
| Parameter | Type | Description |
|---|---|---|
| address (optional) | string | Address of the account to query. Uses the connected account address if no address is given. |
Return Value
balance: The balance in the smallest unit of the native token, ornullwhile loading or when the request failed.loading:truewhile the balance is being fetched.error:trueif fetching the balance failed.nativeTokenSymbol: Thenative_token_symbolof the target network, or"APT"if the network does not define one.
The balance is cached and refetched every 30 seconds. It is also refreshed right after a transaction submitted with useSubmitTransaction is committed on chain, including when the transaction fails, because gas is paid either way. Components that use this hook, such as Balance and the CustomConnectButton, update without waiting for the next poll.