useWalletBalance

Fetch the balance of a wallet in native currency or for a specific token. Leave tokenAddress undefined to fetch the native token balance.

Example

Fetching the native token balance

import { useWalletBalance } from "thirdweb/react";
const { data, isLoading, isError } = useWalletBalance({
chain,
address,
client,
});
console.log("balance", data?.displayValue, data?.symbol);

Fetching a specific token balance

import { useWalletBalance } from "thirdweb/react";
const tokenAddress = "0x..."; // the ERC20 token address
const { data, isLoading, isError } = useWalletBalance({
chain,
address,
client,
tokenAddress,
});
console.log("balance", data?.displayValue, data?.symbol);

Parameters

Returns

GetWalletBalanceResult The result of the query.