Skip to main content
POST
/
net_version
curl --request POST \
  --url https://monad-testnet.core.chainstack.com/9c5b265f20b3ea5df4f54f70eb74b800/ \
  --header 'Content-Type: application/json' \
  --data '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "net_version",
  "params": []
}'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}
Monad API method that returns the current network ID. This method helps identify which network the node is connected to, which is important for ensuring transactions are signed for the correct network.
Get you own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • none

Response

  • result — a string representing the current network ID.

net_version code examples

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");

async function getNetworkVersion() {
  const networkVersion = await provider.send("net_version", []);
  console.log(`Network ID: ${networkVersion}`);
}

getNetworkVersion();

Use case

A practical use case for net_version is validating that your application is connected to the expected network before sending transactions, preventing accidental transactions on the wrong network.

Body

application/json
id
integer
default:1
jsonrpc
string
default:2.0
method
string
default:net_version
params
any[]

Response

200 - application/json

The current network ID.

jsonrpc
string
id
integer
result
string