Docs

wallet/getaccountbalance - Get TRON Account Bal...

Retrieve the native TRX balance of a TRON account at a specific block height. This endpoint returns TRX balance only — it does not return TRC-10 or TRC-20 token balances.

Retrieve the native TRX balance of a TRON account at a specific block height. This endpoint returns TRX balance only — it does not return TRC-10 or TRC-20 token balances.

Use Cases

wallet/getaccountbalance is useful for:

  • Wallet Applications - Display TRX balance at a given block height
  • Payment Verification - Confirm TRX payment receipt at a specific block

For Token Balances

This endpoint does not return token balances. Use the following approaches instead:

GoalEndpoint / Approach
Current TRX balancewallet/getaccount
Current TRC-20 balancewallet/triggerconstantcontract calling balanceOf(address) on the token contract
Historical TRX balancewallet/getaccountbalance
Historical TRC-20 balanceNot natively supported by TRON full nodes; use indexed services (TronScan API, Bitquery, Covalent)

Implementation Examples

Response Examples

Successful Response

JSON
{
  "balance": 1453878299614,
  "block_identifier": {
    "hash": "0000000004dd7431...",
    "number": 81622065
  }
}

Zero Balance Response

JSON
{
  "balance": 0,
  "block_identifier": {
    "hash": "0000000004dd7431...",
    "number": 81622065
  }
}

Common Use Cases

1. TRX Balance Display

JavaScript
async function displayBalance(address) {
  const result = await getAccountBalance(address);
  // Balance is in SUN (1 TRX = 1,000,000 SUN)
  const trx = result.balance / 1_000_000;
  
  return {
    display: `${trx.toFixed(6)} TRX`,
    blockHeight: result.block_identifier.number,
  };
}

2. Payment Confirmation

JavaScript
async function confirmPayment(address, expectedAmount, minConfirmations = 19) {
  const balance = await getAccountBalance(address);
  const currentBlock = balance.block_identifier.number;
  
  // Check if payment received (expectedAmount in SUN)
  const received = balance.balance >= expectedAmount;
  
  // Get latest block to check confirmations
  const latestBlock = await getLatestBlock();
  const confirmations = latestBlock.number - currentBlock;
  
  return {
    received,
    balanceSun: balance.balance,
    balanceTrx: balance.balance / 1_000_000,
    confirmations,
    confirmed: received && confirmations >= minConfirmations
  };
}

3. Balance Change Detection

JavaScript
class BalanceMonitor {
  constructor(apiKey, address) {
    this.apiKey = apiKey;
    this.address = address;
    this.lastBalance = null;
  }
  
  async checkForChanges() {
    const current = await getAccountBalance(this.address);
    
    if (this.lastBalance === null) {
      this.lastBalance = current.balance;
      return { changed: false, balanceSun: current.balance };
    }
    
    const changed = current.balance !== this.lastBalance;
    const difference = current.balance - this.lastBalance;
    
    this.lastBalance = current.balance;
    
    return {
      changed,
      balanceSun: current.balance,
      differenceSun: difference,
      differenceTrx: Math.abs(difference) / 1_000_000,
      direction: difference > 0 ? 'received' : 'sent',
    };
  }
}

Best Practices

  1. Cache Results - Balance queries can be cached for 3 seconds
  2. Batch Requests - Query multiple accounts in parallel
  3. Monitor Changes - Use block height to detect balance changes
  4. Validate Addresses - Check address format before querying

Need help? Contact support or check our TRON documentation.