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,
walletToken: string,
refreshToken?: string
}): Promise<CheckBalanceBatchResponse>
Parameters
tokenAddresses
:string[]
- An array of token addresses.network
:Network
- The network used for transactions. You can use theNetwork
enum to specify the network.walletToken
:string
- The wallet token of the wallet to check the balance for.refreshToken
:string
- The refresh token for authentication. Use this if you want to allow SDK automatically refresh the wallet token.
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.
walletToken
?:string
- The new wallet token of the wallet.refreshToken
?:string
- The new refresh token of the wallet.
Example Usage
const tokenAddresses = [
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
];
const balanceInfo = await sdk.wallet.balanceTokenBatch({
tokenAddresses: tokenAddresses,
network: Network.ETHEREUM,
walletToken: 'your-wallet-token',
refreshToken: 'your-refresh-token' // Optional
});
console.log(balanceInfo);
Response Example
{
"address": "0xBfE64B4b628E0998A03e2522B051Cf1B4661c964",
"tokens": [
{
"balance": "0.0",
"symbol": "USDT",
"decimals": 6
},
{
"balance": "0.0",
"symbol": "USDC",
"decimals": 6
}
],
"walletToken": "your-new-wallet-token",
"refreshToken": "your-new-refresh-token"
}
ℹ️
The SDK will automatically refresh the wallet token and return the new wallet token and refresh token if the refresh token is provided.
ℹ️
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).