SDK
Javascript
How to
Wallet Operation
Check Batch Balance Token

Check Batch Balance Token

This method allows you to check your token balances from a list of token addresses in a blockchain network.

Method Signature

async balanceTokenBatch(tokenAddresses: string[], network: Network): Promise<CheckBalanceBatchResponse>

Parameters

  • tokenAddresses: string[] - An array of token addresses.
  • network: Network - The network used for transactions. You can use the Network enum to specify the network.

Returns

Promise<CheckBalanceBatchResponse> - An object containing the following properties:

  • address: string - The wallet address.
  • tokens: Array - An array of objects, each containing:
    • balance: string - The balance of the token.
    • symbol: string - The symbol of the token.
    • decimals: number - The number of decimal places for the token.

Example Usage

const tokenAddresses = [
  '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
];
const balanceInfo = await sdk.wallet.balanceTokenBatch(tokenAddresses, Network.ETHEREUM);
console.log(balanceInfo);

Response Example

{
  "address": "0xBfE64B4b628E0998A03e2522B051Cf1B4661c964",
  "tokens": [
    {
      "balance": "0.0",
      "symbol": "USDT",
      "decimals": 6
    },
    {
      "balance": "0.0",
      "symbol": "USDC",
      "decimals": 6
    }
  ]
}
ℹ️

The response is an object containing the wallet address and an array of token information, including balance, symbol, and decimals for each specified token address.

Additional Information

  • This method requires a valid wallet token in the SDK configuration.
  • The balance is returned as a string to preserve precision for large numbers.
  • The network parameter determines which blockchain network will be used for checking the token balances.
  • You can check multiple token balances in a single API call, which is more efficient than making separate calls for each token.

For more information, see the Xellar Check Batch Balance Token API Documentation (opens in a new tab).