Get Batch Token Balances
Overview
This SDK method allows you to check the balances of multiple ERC-20 tokens for a smart account in a single request.
Method
xellar.accountAbstraction.balance.getBatchTokenBalances({
accountId: string, // The ID of the smart account
tokenAddresses: string[], // Array of ERC-20 token contract addresses
});
Parameters
accountId
(required): The ID of the smart account to check.tokenAddresses
(required): Array of ERC-20 token contract addresses to check balances for.
Response
The response will include an object with the following properties:
status
(number): The HTTP status code of the response (e.g., 200 for success).message
(string): A message indicating the result of the operation.data
(object): An object containing the batch token balance information:accountId
(string): The ID of the smart account.tokens
(array): List of token balance objects, each containing:balance
(string): The raw token balance in the smallest unit.symbol
(string): The token symbol.decimals
(number): The number of decimals for the token.formattedBalance
(string): The human-readable token balance.
Example Response
{
"status": 200,
"message": "success get batch token balances",
"data": {
"accountId": "68027beb6a1ae347d38563d7",
"tokens": [
{
"balance": "100000",
"symbol": "USDT",
"decimals": 6,
"formattedBalance": "0.1"
}
]
}
}
ℹ️
This method is more efficient than making multiple individual token balance requests when you need to check balances for multiple tokens.
⚠️
Make sure to provide a valid account ID and an array of valid ERC-20 token contract addresses. The request will fail if any of these are invalid or non-existent.
📝
The response includes token metadata (symbol and decimals) for each token, making it easy to display human-readable balances.