[solved] I wanna get balance of Trc-20 USDT

Hello, I wanna get the balance of trc-20 usdt.

After reading this guide, I did getting tron balance. But I don’t know how to get trc-20 balance.

tronService.getTokenBalance require tronAccount, not Account
but the document don’t explain tronAccount. What information is needed for trc-20?

Could I get example about getting trc20 token balance?

I want to know the parameters (tokenaddress, tokenid)

I guess tokenaddress is trc-20 smartcontract address
I don’t know tokenid.

public final class TronAccount public constructor(networkType: com.samsung.android.sdk.blockchain.network.NetworkType, address: kotlin.String, hdPath: kotlin.String, walletId: kotlin.String, tokenAddress: kotlin.String? /* = compiled code /, tokenId: kotlin.String? / = compiled code */) : com.samsung.android.sdk.blockchain.account.Account {


Hello there,

Congratulations on your first post on Samsung Developers, Welcome to the Forums!

You will be able to find programming guidance on TRON Service here.

  • getBalance” API is for fetching the balance of BaseCoin on the TRON platform, which is TRX.

  • As you have the goal to fetch the balance of ‘USDT’ which is a TRC-20 token, at first you have to add this token to an account using the API:
    i.e. addTokenAccount( tronAccount, tokenAddress (trc20) or null, tokenId (trc10) or null)

    tronAccount is the specific account of which you would like to fetch balance.

    And you have to use the tokenAddress(contractAddress) of USDT on the tokenAddress field which is “TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t”

  • getTokenInfo API can be used to fetch basic token information

  • Use getTokenBalance API to fetch the USDT (or any trc20/trc10) balance of an TronAccount.
    i.e. getTokenBalance(tronTokenAccount). In the parameter tronTokenAccount, you have to put the specific tokenAccount that you have added using addTokenAccount API. You can fetch all the accounts using getAccounts API, and apply the getTokenBalance API for the specific tronAccount having the both desired address and tokenAddress.

for (Account account : accountList) {  // accountList using getAccounts API
        TronAccount tronAccount = (TronAccount) account;  // cast Account to TronAccount
         if (tronAccount.getTokenAddress().equals(yourDesiredTokenAddress){
             getTokenBalance(tronAccount);  // set callbacks

You can check out the AeroWallet Sample Application app and source code for example usage.


Hope this helps. Best Regards,
Armaan Ul Islam,
Samsung Developer Program

Yeah!! Thank you. Your answer is really helpful.
I succeeded getting balance.

    TronAccount tronAccount1= new TronAccount(account.getNetworkType(),account.getAddress(), account.getHdPath(),