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: 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
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"net_version","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "net_version",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"net_version","params":[],"jsonrpc":"2.0"},
)
print(resp.json()){
"id": 1,
"result": "1",
"jsonrpc": "2.0"
}Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- 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.