Docs

wallet/getaccountbalance - Get TRON Account Bal...

Quickly retrieve TRON account balance including TRX, TRC10, and TRC20 token balances with block height confirmation via Dwellir's optimized RPC endpoint.

Lightning-Fast Balance Queries

Dwellir's TRON nodes return balance information in under 30ms with real-time synchronization. Get account balances with block height confirmation for accurate balance tracking.

Get your free API key

Retrieve the balance of a TRON account including TRX and all token holdings with the specific block height at which the balance was calculated.

Use Cases

wallet/getaccountbalance is perfect for:

  • Wallet Applications - Display real-time balance updates
  • Exchange Integration - Track deposit confirmations
  • Portfolio Trackers - Monitor multiple asset balances
  • Payment Verification - Confirm payment receipt at specific block
  • Audit Systems - Historical balance verification

Request Parameters

Request
account_identifierobject

Account identification object

account_identifier.addressstring

TRON address (Base58 or Hex)

block_identifierobject

Specific block for balance query

block_identifier.hashstring

Block hash

block_identifier.numbernumber

Block height

visibleboolean

Use Base58 format (default: true)

Response Body

Response
balancenumber

TRX balance in SUN (1 TRX = 1,000,000 SUN)

block_identifierobject

Block at which balance was calculated

block_identifier.hashstring

Block hash

block_identifier.numbernumber

Block height

trc10array

TRC10 token balances

trc20array

TRC20 token balances (requires indexing)

Error Responses

Errors
Error 1400

Invalid address format

Error 2404

Block not found

Error 3429

Rate limit exceeded

Error 4500

Internal server error

Implementation Examples

Bash
# Get current account balance
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": 58234567
    },
    "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
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,
    trc10_count: (.trc10 // [] | length),
    trc20_count: (.trc20 // [] | length)
  }'

Response Examples

Successful Response

JSON
{
  "balance": 15000000000,
  "block_identifier": {
    "hash": "0000000003787ac74d9bb8f8c9c59ac3f3e3b9b8c9e3e8f9c8d7e8f9c8d7e8f9",
    "number": 58234567
  },
  "trc10": [
    {
      "key": "1002000",
      "value": 50000000
    }
  ],
  "trc20": [
    {
      "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
      "value": "100000000",
      "name": "USDT",
      "symbol": "USDT",
      "decimals": 6
    }
  ]
}

Empty Account Response

JSON
{
  "balance": 0,
  "block_identifier": {
    "hash": "0000000003787ac74d9bb8f8c9c59ac3f3e3b9b8c9e3e8f9c8d7e8f9c8d7e8f9",
    "number": 58234567
  },
  "trc10": [],
  "trc20": []
}

Common Use Cases

1. Real-Time Balance Display

JavaScript
async function displayBalance(address) {
  const balance = await getAccountBalance(address);
  
  return {
    display: `${(balance.balance / 1_000_000).toFixed(6)} TRX`,
    blockHeight: balance.block_identifier.number,
    tokens: [
      ...(balance.trc10 || []).map(t => ({ type: 'TRC10', ...t })),
      ...(balance.trc20 || []).map(t => ({ type: 'TRC20', ...t }))
    ]
  };
}

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
  const received = balance.balance >= expectedAmount;
  
  // Get latest block to check confirmations
  const latestBlock = await getLatestBlock();
  const confirmations = latestBlock.number - currentBlock;
  
  return {
    received,
    amount: balance.balance,
    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, balance: current.balance };
    }
    
    const changed = current.balance !== this.lastBalance;
    const difference = current.balance - this.lastBalance;
    
    this.lastBalance = current.balance;
    
    return {
      changed,
      balance: current.balance,
      difference,
      direction: difference > 0 ? 'received' : 'sent',
      amount: Math.abs(difference) / 1_000_000
    };
  }
}

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. Handle Errors - Implement proper error handling and retries
  5. Validate Addresses - Check address format before querying

Need help? Contact support or check our TRON documentation.