TriportRPC

net_version

Last updated:

`net_version` returns the network ID of the network the node is connected to, encoded as a **decimal string**. For Ethereum mainnet this is `"1"`.

Use this method for a quick connectivity check or to detect which network your RPC connection is pointed at. Note that it is distinct from [`eth_chainId`](./eth_chainId.md): `net_version` returns the legacy network ID as a decimal string, while `eth_chainId` returns the EIP-155 chain ID as a hex quantity. The two values happen to coincide on mainnet but are not guaranteed to match on every network. When you need the chain ID for replay-protected transaction signing, prefer `eth_chainId`.

This method takes no parameters and is available on every tier.

Parameters

This method takes no parameters.

Returns

net_version return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"net_version","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "net_version",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"net_version","params":[],"jsonrpc":"2.0"})
print(resp.json())
{
  "id": 1,
  "result": "1",
  "jsonrpc": "2.0"
}

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. Credit cost: 1 per call.

FAQ

What does net_version do?
Returns the current network ID as a decimal string (for example `"1"` for Ethereum mainnet).
How many credits does net_version cost?
net_version costs 1 credit(s) per call on Triport by default.
Is net_version available over WebSocket?
net_version is an HTTP JSON-RPC method.