wallet/getaccountnet
Get detailed bandwidth (network) resource information for an account.
Endpoint
POST /wallet/getaccountnet
Parameters
Required Parameters
Parameter | Type | Description |
---|---|---|
address | string | Account address (base58 or hex) |
Optional Parameters
Parameter | Type | Description |
---|---|---|
visible | boolean | Return base58 addresses (default: false returns hex) |
Response
Returns bandwidth information including:
freeNetUsed
- Free bandwidth used todayfreeNetLimit
- Total free bandwidth available (600 default)NetUsed
- Staked bandwidth usedNetLimit
- Total staked bandwidth availableTotalNetLimit
- Combined total bandwidth limitTotalNetWeight
- Total network bandwidth weightassetNetUsed
- Map of TRC10 token bandwidth usageassetNetLimit
- Map of TRC10 token bandwidth limits
Implementation Examples
- JavaScript
- Python
- cURL
// Get account bandwidth information
const response = await fetch('https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountnet', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
address: 'TYourAddress...',
visible: true
}),
});
const data = await response.json();
// Calculate bandwidth usage
const freeUsagePercent = (data.freeNetUsed / data.freeNetLimit) * 100;
const stakedUsagePercent = data.NetLimit > 0 ? (data.NetUsed / data.NetLimit) * 100 : 0;
console.log('Bandwidth Information:');
console.log(`Free Bandwidth: ${data.freeNetUsed}/${data.freeNetLimit} (${freeUsagePercent.toFixed(1)}%)`);
console.log(`Staked Bandwidth: ${data.NetUsed}/${data.NetLimit} (${stakedUsagePercent.toFixed(1)}%)`);
// Check if needs more bandwidth
const remainingFree = data.freeNetLimit - data.freeNetUsed;
const remainingStaked = data.NetLimit - data.NetUsed;
const totalRemaining = remainingFree + remainingStaked;
if (totalRemaining < 100) {
console.log('Warning: Low bandwidth! Consider staking more TRX.');
}
import requests
url = "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountnet"
payload = {
"address": "TYourAddress...",
"visible": True
}
response = requests.post(url, json=payload)
data = response.json()
# Display bandwidth information
print("=== Bandwidth Information ===")
print(f"Free Bandwidth: {data.get('freeNetUsed', 0)}/{data.get('freeNetLimit', 0)}")
print(f"Staked Bandwidth: {data.get('NetUsed', 0)}/{data.get('NetLimit', 0)}")
# Calculate usage percentages
free_limit = data.get('freeNetLimit', 1)
staked_limit = data.get('NetLimit', 0)
free_usage = (data.get('freeNetUsed', 0) / free_limit * 100) if free_limit > 0 else 0
staked_usage = (data.get('NetUsed', 0) / staked_limit * 100) if staked_limit > 0 else 0
print(f"\nUsage Rates:")
print(f" Free: {free_usage:.1f}%")
print(f" Staked: {staked_usage:.1f}%")
# Check TRC10 token bandwidth
asset_net = data.get('assetNetUsed', {})
if asset_net:
print("\nTRC10 Token Bandwidth:")
for token_id, used in asset_net.items():
limit = data.get('assetNetLimit', {}).get(token_id, 0)
print(f" Token {token_id}: {used}/{limit}")
# Get bandwidth info with base58 address
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountnet \
-H "Content-Type: application/json" \
-d '{
"address": "TYourAddress...",
"visible": true
}'
# Get bandwidth info with hex address
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountnet \
-H "Content-Type: application/json" \
-d '{
"address": "41e552726909b5c951a9e0d365674e5a48b46f79d3"
}'
Example Response
{
"freeNetUsed": 245,
"freeNetLimit": 600,
"NetUsed": 1250,
"NetLimit": 5000,
"TotalNetLimit": 43200000000,
"TotalNetWeight": 84598395898,
"assetNetUsed": {
"1000001": 50
},
"assetNetLimit": {
"1000001": 1000
}
}
Bandwidth Calculation
// Calculate bandwidth costs for transactions
function calculateBandwidthNeeded(transactionSize) {
// Basic transaction is ~200 bytes
// Smart contract calls can be 300-500 bytes
return transactionSize;
}
// Calculate TRX needed for bandwidth
function calculateTRXForBandwidth(bandwidthNeeded) {
// 1 TRX = 1 bandwidth point when staked
return bandwidthNeeded;
}
// Example: Check if account has enough bandwidth
async function checkBandwidth(address, transactionSize) {
const response = await fetch(`${API_URL}/wallet/getaccountnet`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ address, visible: true })
});
const data = await response.json();
const availableFree = data.freeNetLimit - data.freeNetUsed;
const availableStaked = data.NetLimit - data.NetUsed;
const totalAvailable = availableFree + availableStaked;
return {
hasEnough: totalAvailable >= transactionSize,
available: totalAvailable,
needed: transactionSize,
deficit: Math.max(0, transactionSize - totalAvailable)
};
}
Bandwidth Management
Daily Reset
- Free bandwidth resets daily at 00:00 UTC
- Staked bandwidth usage resets daily
- TRC10 token bandwidth resets based on token settings
Priority Order
- TRC10 Token Bandwidth: Used first for token transfers
- Free Bandwidth: 600 points daily for all accounts
- Staked Bandwidth: From frozen TRX
- TRX Burning: If no bandwidth available, burns TRX
Bandwidth Consumption
Operation | Typical Bandwidth |
---|---|
TRX Transfer | ~250 points |
TRC10 Transfer | ~300 points |
Smart Contract Call | 350-500 points |
Account Creation | ~1000 points |
Multi-signature | +100 points per signature |
Best Practices
1. Monitor Usage
// Check bandwidth before transactions
const bandwidth = await getAccountNet(address);
if (bandwidth.freeNetUsed > 500) {
console.warn('Consider staking TRX for more bandwidth');
}
2. Optimize Transactions
- Batch operations when possible
- Minimize transaction data size
- Use efficient contract calls
3. Resource Planning
- Keep buffer of 100+ bandwidth points
- Stake TRX if doing frequent transactions
- Monitor daily reset timing
Use Cases
- Resource Monitoring: Track bandwidth consumption
- Transaction Planning: Ensure sufficient bandwidth before sending
- Cost Optimization: Decide between using free/staked bandwidth or burning TRX
- DApp Integration: Check user bandwidth before operations
- Alert Systems: Notify when bandwidth is low
Related Methods
- wallet/getaccountresource - Get complete resource info
- wallet/freezebalancev2 - Stake TRX for bandwidth
- wallet/getaccount - Get account details