net_version
Returns the current network ID.
When to Use This Method
Use net_version
to:
- Identify Network - Get network identifier
- Verify Connection - Confirm correct network
- Multi-Network Support - Switch between networks
Parameters
No parameters required.
{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}
Returns
String
- The current network ID:
"7000"
for xdc mainnet"7001"
for Athens testnet
Implementation Examples
- JavaScript
- Python
const networkId = await provider.send('net_version', []);
console.log('Network ID:', networkId); // "7000"
network_id = w3.net.version
print(f'Network ID: {network_id}') # "7000"
Related Methods
- eth_chainId - Get chain ID
- net_listening - Network status