Glacier Hooks
Hooks for interacting with Glacier API and blockchain data.
Glacier Hooks
BuilderKit provides hooks for interacting with the Glacier API, which provides blockchain data and token information.
useGlacier
The useGlacier
hook provides functions for accessing chain information and token balances through Glacier.
import { useGlacier } from '@avalabs/builderkit';
const {
getChainInformation,
listErc20Balances
} = useGlacier();
// Get chain information
const chainInfo = await getChainInformation(43114);
// Get ERC20 token balances
const balances = await listErc20Balances(
43114, // Chain ID
"0x1234..." // Wallet address
);
Available Functions
getChainInformation(chain_id: number)
: Get detailed information about a chainlistErc20Balances(chain_id: number, address: string)
: Get all ERC20 token balances for an address
Integration Example
function TokenBalances({ address }: { address: string }) {
const { listErc20Balances } = useGlacier();
const [balances, setBalances] = useState([]);
useEffect(() => {
const fetchBalances = async () => {
const tokenBalances = await listErc20Balances(43114, address);
setBalances(tokenBalances);
};
fetchBalances();
}, [address]);
return (
<div className="space-y-2">
{balances.map(balance => (
<div key={balance.token_address} className="flex justify-between">
<span>{balance.symbol}</span>
<span>{balance.formatted_amount}</span>
</div>
))}
</div>
);
}
Last updated on 3/10/2025