For the complete documentation index, see llms.txt. This page is also available as Markdown.

net_version - Ethereum

Example code for the net_version JSON RPC method. Сomplete guide on how to use net_version JSON RPC in GetBlock Web3 documentation.

This method returns the current network ID as a decimal string. For Ethereum mainnet the value is "1". Network ID historically distinguished chains before the eth_chainId method was standardized; modern applications generally prefer eth_chainId for chain-selection logic.

Parameters

This method takes no parameters.

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "net_version",
    "params": [],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'net_version',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'net_version',
        'params': [],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "1"
}

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

string

Network ID as a decimal string ("1" for Ethereum mainnet, "11155111" for Sepolia, "560048" for Hoodi)

Use Cases

  • Legacy Chain Detection: Support older tooling that predates eth_chainId standardization

  • Cross-Reference Verification: Sanity-check that net_version and eth_chainId agree (they generally do on Ethereum-derived chains)

  • Endpoint Environment Discovery: Detect whether an endpoint points to mainnet vs a testnet without knowing in advance

  • Multi-Chain Dashboards: Display the network name in an administrative UI by looking up the ID

Error Handling

Error Code
Message
Description

-32603

Internal error

Node failed to determine its network ID

Web3 Integration

Was this helpful?