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]

Best Practices

  • Use eth_chainId for transaction signing (EIP-155 replay protection) -- net_version is 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_chainId for 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 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