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:
| Goal | Endpoint / Approach |
|---|---|
| Current TRX balance | wallet/getaccount |
| Current TRC-20 balance | wallet/triggerconstantcontract calling balanceOf(address) on the token contract |
| Historical TRX balance | wallet/getaccountbalance |
| Historical TRC-20 balance | Not natively supported by TRON full nodes; use indexed services (TronScan API, Bitquery, Covalent) |
Implementation Examples
# 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
{
"balance": 1453878299614,
"block_identifier": {
"hash": "0000000004dd7431...",
"number": 81622065
}
}Zero Balance Response
{
"balance": 0,
"block_identifier": {
"hash": "0000000004dd7431...",
"number": 81622065
}
}Common Use Cases
1. TRX Balance Display
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
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
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
- Cache Results - Balance queries can be cached for 3 seconds
- Batch Requests - Query multiple accounts in parallel
- Monitor Changes - Use block height to detect balance changes
- Validate Addresses - Check address format before querying
Related Methods
- wallet/getaccount - Get detailed account information (including current TRX balance)
- wallet/getaccountresource - Get resource details
- wallet/validateaddress - Validate address format
- wallet/getaccountnet - Get bandwidth usage
Need help? Contact support or check our TRON documentation.
wallet/getaccount
Get comprehensive TRON account information including TRX balance, resources, TRC20 tokens, and account permissions via Dwellir's optimized RPC endpoint.
wallet/getaccountresource
Get TRON account bandwidth and energy resources for transaction fee optimization. Monitor resource usage and manage stake efficiently with Dwellir RPC.