net_version - Somnia

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

This method returns the current network ID on the Somnia network. The network ID is typically the same as the chain ID (5031 for Mainnet, 50312 for Testnet) and is used for network identification.

Parameters

  • None

Request Example

curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "net_version",
  "params": []
}'

Response Example

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

Response Parameters

Parameter
Type
Description

result

string

Network ID as string (5031 for Mainnet)

Use Cases

  • Verify connected network

  • Network detection in multi-chain apps

  • Configuration validation

  • Legacy compatibility checks

Error Handling

Error Code
Description

-32603

Internal error - node processing issues

SDK Integration

Last updated

Was this helpful?