Balances
This guide explains how to fetch native and ERC20 token balances.
You MUST be authenticated as Account Owner or Account Manager to make this request.
- TypeScript
- GraphQL
- React
Use the fetchBalancesBulk action to fetch a finite number of balances for the specific address.
This response differs slightly from others by providing a localized error for each balance that couldn’t be fetched. This enables more graceful error handling, allowing you to display some balances even if others fail.
Example
for (let balance of balances) { switch (balance.__typename) { case "Erc20Amount": console.log(`${balance.value} ${balance.asset.symbol}`); break;
case "NativeAmount": console.log(`${balance.value} ${balance.asset.symbol}`);
case "Erc20BalanceError": case "NativeBalanceError": console.error(balance.reason); }}