⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

wallet/getnodeinfo

Real-Time Node Monitoring

Dwellir's TRON infrastructure provides instant node status with version info, sync state, and network connectivity. Monitor node health and configuration for optimal integration.

Access node information →

Retrieve detailed information about the connected TRON node including software version, network configuration, current block height, and peer connections.

Use Cases

wallet/getnodeinfo is crucial for:

  • Health Monitoring - Check node status and sync state
  • Version Tracking - Verify node software version
  • Network Analysis - Monitor peer connections
  • Configuration Audit - Review node settings
  • Debugging - Troubleshoot connection issues

Parameters

This method requires no parameters.

Request Example

{}

Response Fields

FieldTypeDescription
beginSyncNumnumberBlock number when sync started
blockstringCurrent block hash and height
solidityBlockstringLatest solidified block
currentConnectCountnumberCurrent peer connections
activeConnectCountnumberActive peer connections
passiveConnectCountnumberPassive peer connections
totalFlownumberTotal network traffic
peerListarrayConnected peer information
configNodeInfoobjectNode configuration details
machineInfoobjectHardware and OS information
cheatWitnessInfoMapobjectWitness validation info

Implementation Examples

const TRON_API = 'https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY';

// Get basic node information
async function getNodeInfo() {
const response = await fetch(`${TRON_API}/wallet/getnodeinfo`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

return await response.json();
}

// Comprehensive node monitor
class TronNodeMonitor {
constructor(apiKey) {
this.apiUrl = `https://api-tron-mainnet.n.dwellir.com/${apiKey}`;
this.lastInfo = null;
this.alerts = [];
}

async fetchNodeInfo() {
const response = await fetch(`${this.apiUrl}/wallet/getnodeinfo`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({})
});

if (!response.ok) {
throw new Error(`Node info request failed: ${response.statusText}`);
}

return await response.json();
}

async getStatus() {
try {
const info = await this.fetchNodeInfo();

// Parse block information
const blockInfo = this.parseBlockInfo(info.block);
const solidityBlockInfo = this.parseBlockInfo(info.solidityBlock);

// Calculate sync status
const syncLag = blockInfo.number - solidityBlockInfo.number;
const isSynced = syncLag < 100; // Consider synced if less than 100 blocks behind

return {
online: true,
version: info.configNodeInfo?.codeVersion || 'Unknown',
network: info.configNodeInfo?.network || 'mainnet',
currentBlock: blockInfo.number,
solidityBlock: solidityBlockInfo.number,
syncLag: syncLag,
isSynced: isSynced,
peers: {
total: info.currentConnectCount || 0,
active: info.activeConnectCount || 0,
passive: info.passiveConnectCount || 0
},
traffic: this.formatBytes(info.totalFlow || 0),
timestamp: new Date().toISOString()
};
} catch (error) {
return {
online: false,
error: error.message,
timestamp: new Date().toISOString()
};
}
}

parseBlockInfo(blockString) {
if (!blockString) return { hash: null, number: 0 };

// Format: "Num:12345,ID:hash"
const parts = blockString.split(',');
const num = parts[0]?.split(':')[1] || '0';
const id = parts[1]?.split(':')[1] || '';

return {
number: parseInt(num, 10),
hash: id
};
}

async getDetailedInfo() {
const info = await this.fetchNodeInfo();

return {
basic: {
version: info.configNodeInfo?.codeVersion,
network: info.configNodeInfo?.network,
dbVersion: info.configNodeInfo?.dbVersion,
p2pVersion: info.configNodeInfo?.p2pVersion
},
sync: {
beginBlock: info.beginSyncNum,
currentBlock: this.parseBlockInfo(info.block).number,
solidityBlock: this.parseBlockInfo(info.solidityBlock).number,
needSync: info.needSync
},
network: {
listenPort: info.configNodeInfo?.listenPort,
discoveryEnabled: info.configNodeInfo?.discoverEnabled,
activeNodes: info.configNodeInfo?.activeNodeSize,
passiveNodes: info.configNodeInfo?.passiveNodeSize,
maxConnections: info.configNodeInfo?.maxConnectCount
},
peers: this.analyzePeers(info.peerList || []),
machine: {
cpuCount: info.machineInfo?.cpuCount,
cpuRate: info.machineInfo?.cpuRate,
memoryUsage: info.machineInfo?.memoryDescInfo,
javaVersion: info.machineInfo?.javaVersion,
osName: info.machineInfo?.osName,
totalMemory: info.machineInfo?.totalMemory,
freeMemory: info.machineInfo?.freeMemory
}
};
}

analyzePeers(peerList) {
const analysis = {
total: peerList.length,
byVersion: {},
byCountry: {},
avgLatency: 0,
topPeers: []
};

let totalLatency = 0;

peerList.forEach(peer => {
// Count by version
const version = peer.nodeInfo?.codeVersion || 'Unknown';
analysis.byVersion[version] = (analysis.byVersion[version] || 0) + 1;

// Track latency
if (peer.avgLatency) {
totalLatency += peer.avgLatency;
}

// Add to top peers
analysis.topPeers.push({
address: peer.host,
port: peer.port,
latency: peer.avgLatency,
version: version,
blockHeight: peer.blockInNum,
connected: peer.connectTime
});
});

// Calculate average latency
if (peerList.length > 0) {
analysis.avgLatency = Math.round(totalLatency / peerList.length);
}

// Sort top peers by block height
analysis.topPeers.sort((a, b) => b.blockHeight - a.blockHeight);
analysis.topPeers = analysis.topPeers.slice(0, 10);

return analysis;
}

async monitorHealth(intervalMs = 60000) {
const checkHealth = async () => {
const status = await this.getStatus();

// Check for issues
if (!status.online) {
this.addAlert('error', 'Node is offline', status);
} else if (!status.isSynced) {
this.addAlert('warning', `Node is ${status.syncLag} blocks behind`, status);
} else if (status.peers.total < 5) {
this.addAlert('warning', `Low peer count: ${status.peers.total}`, status);
}

this.lastInfo = status;
return status;
};

// Initial check
await checkHealth();

// Set up monitoring interval
return setInterval(checkHealth, intervalMs);
}

addAlert(level, message, data) {
const alert = {
level,
message,
data,
timestamp: new Date().toISOString()
};

this.alerts.push(alert);

// Keep only last 100 alerts
if (this.alerts.length > 100) {
this.alerts = this.alerts.slice(-100);
}

// Trigger alert handler if configured
this.onAlert?.(alert);
}

getAlerts(level = null) {
if (level) {
return this.alerts.filter(a => a.level === level);
}
return this.alerts;
}

formatBytes(bytes) {
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) return '0 B';
const i = Math.floor(Math.log(bytes) / Math.log(1024));
return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
}
}

// Dashboard component
class NodeDashboard {
constructor(apiKey) {
this.monitor = new TronNodeMonitor(apiKey);
this.updateInterval = null;
}

async start(elementId, refreshInterval = 30000) {
const container = document.getElementById(elementId);
if (!container) return;

const update = async () => {
const status = await this.monitor.getStatus();
container.innerHTML = this.renderDashboard(status);
};

// Initial render
await update();

// Set up auto-refresh
this.updateInterval = setInterval(update, refreshInterval);
}

renderDashboard(status) {
if (!status.online) {
return `
<div class="node-dashboard error">
<h3>⚠️ Node Offline</h3>
<p>Error: ${status.error}</p>
<p>Last check: ${status.timestamp}</p>
</div>
`;
}

const syncStatus = status.isSynced ?
'<span class="badge success">Synced</span>' :
`<span class="badge warning">Syncing (${status.syncLag} blocks behind)</span>`;

return `
<div class="node-dashboard">
<h3>TRON Node Status</h3>
<div class="status-grid">
<div class="status-item">
<label>Version:</label>
<span>${status.version}</span>
</div>
<div class="status-item">
<label>Network:</label>
<span>${status.network}</span>
</div>
<div class="status-item">
<label>Current Block:</label>
<span>${status.currentBlock.toLocaleString()}</span>
</div>
<div class="status-item">
<label>Sync Status:</label>
${syncStatus}
</div>
<div class="status-item">
<label>Peers:</label>
<span>${status.peers.total} (${status.peers.active} active)</span>
</div>
<div class="status-item">
<label>Traffic:</label>
<span>${status.traffic}</span>
</div>
</div>
<p class="updated">Updated: ${new Date(status.timestamp).toLocaleTimeString()}</p>
</div>
`;
}

stop() {
if (this.updateInterval) {
clearInterval(this.updateInterval);
this.updateInterval = null;
}
}
}

// Usage examples
(async () => {
const monitor = new TronNodeMonitor('YOUR_API_KEY');

try {
// Get basic status
const status = await monitor.getStatus();
console.log('Node Status:', status);

// Get detailed information
const detailed = await monitor.getDetailedInfo();
console.log('Detailed Info:', detailed);

// Set up health monitoring
monitor.onAlert = (alert) => {
console.log(`[${alert.level.toUpperCase()}] ${alert.message}`);
};

const monitorHandle = await monitor.monitorHealth(60000);

// Start dashboard (if in browser)
if (typeof document !== 'undefined') {
const dashboard = new NodeDashboard('YOUR_API_KEY');
await dashboard.start('node-status', 30000);
}

// Stop monitoring after 5 minutes
setTimeout(() => {
clearInterval(monitorHandle);
console.log('Monitoring stopped');
}, 5 * 60 * 1000);

} catch (error) {
console.error('Error:', error);
}
})();

Response Example

{
"beginSyncNum": 58000000,
"block": "Num:58234567,ID:0000000003787ac74d9bb8f8c9c59ac3f3e3b9b8c9e3e8f9",
"solidityBlock": "Num:58234547,ID:0000000003787ab34d9bb8f8c9c59ac3f3e3b9b8c9e3e8f8",
"currentConnectCount": 30,
"activeConnectCount": 18,
"passiveConnectCount": 12,
"totalFlow": 1234567890,
"peerList": [
{
"host": "192.168.1.100",
"port": 18888,
"avgLatency": 45,
"blockInNum": 58234567,
"connectTime": 1702456789000,
"nodeInfo": {
"codeVersion": "4.7.2",
"p2pVersion": "1.0.0"
}
}
],
"configNodeInfo": {
"codeVersion": "4.7.2",
"versionName": "GreatVoyage-v4.7.2",
"versionNum": "17766",
"p2pVersion": "11111",
"listenPort": 18888,
"discoverEnable": true,
"activeNodeSize": 18,
"passiveNodeSize": 12,
"sendNodeSize": 30,
"maxConnectCount": 50,
"sameIpMaxConnectCount": 2,
"backupListenPort": 10001,
"backupMemberSize": 0,
"backupPriority": 8,
"dbVersion": 2,
"minParticipationRate": 15,
"supportConstant": true,
"minTimeRatio": 0.6,
"maxTimeRatio": 5.0,
"allowCreationOfContracts": 0,
"allowAdaptiveEnergy": 0
},
"machineInfo": {
"threadCount": 150,
"deadLockThreadCount": 0,
"cpuCount": 16,
"totalMemory": 34359738368,
"freeMemory": 12884901888,
"cpuRate": 0.35,
"javaVersion": "1.8.0_292",
"osName": "Linux",
"jvmTotalMemory": 8589934592,
"jvmFreeMemory": 4294967296,
"processCpuRate": 0.25,
"memoryDescInfo": "Total: 32GB, Free: 12GB, Usage: 62.5%",
"deadLockThreadInfoList": []
},
"cheatWitnessInfoMap": {}
}

Common Use Cases

1. Health Check Endpoint

async function healthCheck() {
try {
const info = await getNodeInfo();
const blockInfo = parseBlockString(info.block);
const solidityInfo = parseBlockString(info.solidityBlock);

const healthy =
info.currentConnectCount > 5 &&
(blockInfo.number - solidityInfo.number) < 100;

return {
status: healthy ? 'healthy' : 'degraded',
details: {
peers: info.currentConnectCount,
syncLag: blockInfo.number - solidityInfo.number,
version: info.configNodeInfo?.codeVersion
}
};
} catch (error) {
return {
status: 'unhealthy',
error: error.message
};
}
}

2. Version Compatibility Check

async function checkCompatibility(requiredVersion) {
const info = await getNodeInfo();
const nodeVersion = info.configNodeInfo?.codeVersion || '0.0.0';

return {
compatible: compareVersions(nodeVersion, requiredVersion) >= 0,
nodeVersion,
requiredVersion
};
}

3. Network Statistics

async function getNetworkStats() {
const info = await getNodeInfo();

// Analyze peer versions
const versionStats = {};
info.peerList?.forEach(peer => {
const version = peer.nodeInfo?.codeVersion || 'Unknown';
versionStats[version] = (versionStats[version] || 0) + 1;
});

return {
totalPeers: info.currentConnectCount,
activePeers: info.activeConnectCount,
passivePeers: info.passiveConnectCount,
versionDistribution: versionStats,
networkTraffic: formatBytes(info.totalFlow)
};
}

Best Practices

  1. Cache Results - Node info can be cached for 30-60 seconds
  2. Monitor Regularly - Check node health every 1-5 minutes
  3. Alert Thresholds - Set alerts for low peers or high sync lag
  4. Version Tracking - Monitor node version for required updates
  5. Fallback Nodes - Have backup nodes ready if health degrades

Need help? Contact support or visit our TRON documentation.