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

Bash
# Get account balance at current block
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountbalance" \
  -H "Content-Type: application/json" \
  -d '{
    "account_identifier": {
      "address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN"
    },
    "visible": true
  }'

# Get balance at specific block height
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountbalance" \
  -H "Content-Type: application/json" \
  -d '{
    "account_identifier": {
      "address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN"
    },
    "block_identifier": {
      "number": 81622065
    },
    "visible": true
  }'

# Get balance with hex address format
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountbalance" \
  -H "Content-Type: application/json" \
  -d '{
    "account_identifier": {
      "address": "41E552F6487585C2B58BC2C9BB4492BC1F17132CD0"
    },
    "visible": false
  }'

# Parse balance with jq (balance is in SUN; divide by 1,000,000 for TRX)
curl -s -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountbalance" \
  -H "Content-Type: application/json" \
  -d '{
    "account_identifier": {
      "address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN"
    },
    "visible": true
  }' | jq '{
    trx_balance: (.balance // 0) / 1000000,
    sun_balance: .balance // 0,
    block_height: .block_identifier.number,
    block_hash: .block_identifier.hash
  }'

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.