net_version - TRON RPC Method
Get the current network ID on TRON. Useful for endpoint identification and multi-network routing.
TRON RPC endpoint: endpoint URLs, plans and pricing.
Returns the current network ID on TRON as a decimal string. The network ID identifies which network the node is connected to.
Why TRON? Build on the TVM-compatible Layer 1 for TRC-20 payments, wallet APIs, and low-cost smart contract execution with TVM compatibility paired with native TRON wallet APIs, DPoS block production, and low-cost transaction flows.
When to Use This Method
net_version is essential for TRON developers building payment rails, exchanges, and consumer crypto applications:
- Endpoint Identification - Confirm your application is connected to the expected TRON network
- Multi-Chain App Routing - Dynamically detect which network an RPC endpoint serves and route logic accordingly
- Connection Validation - Perform a quick sanity check during node or provider initialization
Current Network ID
TRON mainnet currently returns 0x2b6653dc from both net_version and eth_chainId on Dwellir's shared JSON-RPC endpoint. Treat that value as the canonical identity check when you are validating routing, signing, or environment selection in production code.
{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}Code Examples
Common Use Cases
1. Gate startup on the expected TRON network ID
async function assertTronMainnet(provider) {
const networkId = await provider.send('net_version', []);
if (networkId !== '0x2b6653dc') {
throw new Error(`Unexpected TRON network ID: ${networkId}`);
}
return networkId;
}2. Cross-check net_version and eth_chainId
async function readTronIdentity(provider) {
const [networkId, chainId] = await Promise.all([
provider.send('net_version', []),
provider.send('eth_chainId', []),
]);
console.log({ networkId, chainId });
if (networkId !== chainId) {
throw new Error(`TRON identity mismatch: ${networkId} vs ${chainId}`);
}
return { networkId, chainId };
}3. Route environment-specific config
TRON_NETWORKS = {
'0x2b6653dc': 'tron-mainnet',
}
def resolve_tron_environment(network_id: str) -> str:
if network_id not in TRON_NETWORKS:
raise ValueError(f'Unsupported TRON network id: {network_id}')
return TRON_NETWORKS[network_id]Best Practices
- Use
eth_chainIdfor transaction signing (EIP-155 replay protection) --net_versionis for network identification only - Cache the network ID at startup -- it does not change during a session
- Some L2 and sidechain networks share the same network ID as their L1 -- always combine with
eth_chainIdfor unambiguous identification - For multi-chain dApps, maintain a mapping of network IDs to chain-specific contract addresses and RPC endpoints
- The
net_*namespace may be disabled on some node configurations -- handle the -32601 error gracefully
Error Handling
| Error Code | Description | Solution |
|---|---|---|
| -32601 | Method not found | The node may have the net namespace disabled -- check node startup flags |
| -32603 | Internal error | Node may be starting up -- retry after delay |
| -32005 | Rate limit exceeded | Reduce polling frequency or implement backoff |
Related Methods
eth_chainId- Get the EIP-155 chain ID (preferred for transaction signing)net_listening- Check whether the client reports peer-listening statenet_peerCount- Get number of connected peerseth_syncing- Check node sync progress
eth_syncing
Check the sync status of your TRON node. Returns sync progress or false when fully synced - essential for node health monitoring and dApp reliability.
net_listening
Check the legacy net_listening compatibility method on TRON. Public endpoints may return a boolean or an unsupported-method response depending on the client.