Docs

net_version - TRON RPC Method

Get the current network ID on TRON. Useful for endpoint identification and multi-network routing.

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.

Code Examples

Common Use Cases

1. Gate startup on the expected TRON network ID

JavaScript
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

JavaScript
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

Python
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]

Error Handling

Error CodeDescriptionSolution
-32601Method not foundThe node may have the net namespace disabled — check node startup flags
-32603Internal errorNode may be starting up — retry after delay
-32005Rate limit exceededReduce polling frequency or implement backoff