Get Token Balance
Overview
This SDK method allows you to check the ERC-20 token balance of a smart account.
Method
xellar.accountAbstraction.balance.getTokenBalance({
accountId: string, // The ID of the smart account
tokenAddress: string, // The ERC-20 token contract address
});
Parameters
accountId
(required): The ID of the smart account to check.tokenAddress
(required): The ERC-20 token contract address.
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 token balance information: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 token balance",
"data": {
"balance": "100000",
"symbol": "USDT",
"decimals": 6,
"formattedBalance": "0.1"
}
}
ℹ️
The balance is returned in both raw format (in the smallest unit) and a human-readable format, along with token metadata like symbol and decimals.
⚠️
Make sure to provide both a valid account ID and a valid ERC-20 token contract address. The request will fail if either is invalid or non-existent.