Get the token balances for a given account.
Constructor | Description |
| Initializes the AccountBalanceQuery object |
new AccountBalanceQuery()
Method | Type | Requirement |
| TokenId | Required |
Java//Create the queryAccountBalanceQuery query = new AccountBalanceQuery().setAccountId(accountId);​//Sign with the operator private key and submit to a Hedera networkAccountBalance tokenBalance = query.execute(client);​System.out.println("The token balance(s) for this account: " +tokenBalance.token);​//v2.0.1
JavaScript//Create the queryconst query = new AccountBalanceQuery().setAccountId(accountId);​//Sign with the client operator private key and submit to a Hedera networkconst tokenBalance = await query.execute(client);​console.log("The token balance(s) for this account: " +tokenBalance.tokens.toString());​//v2.0.7
Go//Create the queryquery := hedera.NewAccountBalanceQuery().SetAccountID(accountId)//Sign with the client operator private key and submit to a Hedera networktokenbalance, err := query.Execute(client)​if err != nil {panic(err)}​fmt.Printf("The token balance(s) for this account: %v\n", tokenBalance)​//v2.1.0
Constructor | Description |
| Initializes the TokenBalanceQuery object |
new TokenBalanceQuery()
Method | Type | Requirement |
| TokenId | Required |
JavaMap<TokenId, Long> tokenBalance = new TokenBalanceQuery().setAccountId(accountId).execute(client);​System.out.println("The token balance(s) for this account: " +tokenBalance);//Version: 1.2.2
JavaScriptconst tokenBalance = await new TokenBalanceQuery().setAccountId(accountId).execute(client);​console.log("The token balance(s) for this account: " +tokenBalance.get("<tokenId>"));//Version 1.4.2
​
​