Docs

net_version - Boba Network RPC Method

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

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

Why Boba Network? Build on the Hybrid Compute L2 enabling smart contracts to access AI models and Web2 APIs natively with HybridCompute 2.0 for native AI/API access, $70M ecosystem funding, OP Stack compatibility, and two-way offchain integration.

When to Use This Method

net_version is essential for AI dApp developers, enterprise integration teams, and builders requiring offchain compute access:

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

Code Examples

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