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.
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
Account identification object
TRON address (Base58 or Hex)
Specific block for balance query
Block hash
Block height
Use Base58 format (default: true)
Response Body
TRX balance in SUN (1 TRX = 1,000,000 SUN)
Block at which balance was calculated
Block hash
Block height
TRC10 token balances
TRC20 token balances (requires indexing)
Error Responses
Invalid address format
Block not found
Rate limit exceeded
Internal server error
Implementation Examples
# 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
{
"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
{
"balance": 0,
"block_identifier": {
"hash": "0000000003787ac74d9bb8f8c9c59ac3f3e3b9b8c9e3e8f9c8d7e8f9c8d7e8f9",
"number": 58234567
},
"trc10": [],
"trc20": []
}Common Use Cases
1. Real-Time Balance Display
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
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
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
- 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
- Handle Errors - Implement proper error handling and retries
- Validate Addresses - Check address format before querying
Related Methods
- wallet/getaccount - Get detailed account information
- 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.