net_version - Base
Example code for the net_version JSON-RPC method. Complete guide on how to use net_version JSON-RPC in GetBlock Web3 documentation.
The net_version method returns the current network ID. For Base mainnet, this returns "8453". This method is primarily used for legacy compatibility, as eth_chainId is the preferred method for modern applications.
Parameters
None
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"
}'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('Network ID:', response.data.result);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'
}
)
result = response.json()
print(f'Network ID: {result["result"]}')Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "8453"
}Response Parameters
jsonrpc
string
JSON-RPC protocol version ("2.0")
id
string
Request identifier matching the request
result
string
Network ID as a decimal string
Use Cases
Network Verification: Confirm connection to expected network
Legacy Compatibility: Support older wallet integrations
Multi-network Apps: Route connections to correct network
Configuration Validation: Verify RPC endpoint configuration
Error Handling
-32603
Internal error
Node internal failure
Web3 Integration
Last updated
Was this helpful?