Docs
Supported ChainsZetachainJSON-RPC APINetwork Methods

net_version - Zetachain RPC Method

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

Returns the current network ID on Zetachain as a decimal string. The network ID identifies which network the node is connected to.

Why Zetachain? Build on the universal omnichain blockchain enabling cross-chain smart contracts across 50+ chains including Bitcoin with native Bitcoin support, 50+ chain interoperability via UNISON, no bridging required, and partnerships with Curve and SushiSwap.

When to Use This Method

net_version is essential for cross-chain dApp developers, Bitcoin DeFi builders, and teams requiring native multi-chain interoperability:

  • Endpoint Identification — Confirm your application is connected to the expected Zetachain 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

Request Parameters

Request

This method accepts no parameters.

Response Body

Response
resultString

The current network ID as a decimal string (e.g., "1" for Ethereum mainnet, "5" for Goerli)

Error Responses

Errors
Error Response-32601

Code Examples

Bash
curl -X POST https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "net_version",
    "params": [],
    "id": 1
  }'

Common Use Cases

1. Multi-Chain Connection Validator

Verify your application connects to the expected network before processing any transactions:

JavaScript
const EXPECTED_NETWORKS = {
  '1': 'Ethereum Mainnet',
  '137': 'Polygon',
  '42161': 'Arbitrum One',
  '10': 'Optimism',
};

async function validateNetwork(provider, expectedNetworkId) {
  const networkId = await provider.send('net_version', []);

  if (networkId !== expectedNetworkId) {
    const actual = EXPECTED_NETWORKS[networkId] || `Unknown (${networkId})`;
    const expected = EXPECTED_NETWORKS[expectedNetworkId] || expectedNetworkId;
    throw new Error(`Wrong network: connected to ${actual}, expected ${expected}`);
  }

  console.log(`Connected to ${EXPECTED_NETWORKS[networkId]}`);
  return networkId;
}

2. Dynamic Chain Router

Route application logic based on the detected network:

JavaScript
async function createChainRouter(rpcUrl) {
  const provider = new JsonRpcProvider(rpcUrl);
  const networkId = await provider.send('net_version', []);

  const config = {
    '1': { explorer: 'https://etherscan.io', confirmations: 12 },
    '137': { explorer: 'https://polygonscan.com', confirmations: 128 },
    '42161': { explorer: 'https://arbiscan.io', confirmations: 1 },
  };

  if (!config[networkId]) {
    throw new Error(`Unsupported network ID: ${networkId}`);
  }

  return { provider, networkId, ...config[networkId] };
}

3. Network ID vs Chain ID Comparison

Compare net_version with eth_chainId when you need both endpoint identity and signing context:

Python
from web3 import Web3

def verify_chain_identity(rpc_url):
    w3 = Web3(Web3.HTTPProvider(rpc_url))

    network_id = int(w3.net.version)
    chain_id = w3.eth.chain_id

    if network_id != chain_id:
        print(f'Network ID ({network_id}) differs from chain ID ({chain_id})')
    else:
        print(f'Network and chain ID match: {chain_id}')

    print('Use eth_chainId as the signing source of truth')

    return {'network_id': network_id, 'chain_id': chain_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