net_version
https://api.triport.io/v1/polygonReturns the network ID as a decimal string — `"137"` for Polygon mainnet.
net_version returns the network identifier of the connected chain as a
decimal string. For Polygon mainnet the value is "137".
This is a legacy companion to eth_chainId: both identify
the chain, but net_version returns a decimal string ("137") while
eth_chainId returns a hex quantity (0x89). Web3.js versions before 4.x call
net_version during network detection, which is the main reason to keep it
around. For new integrations prefer eth_chainId — it is the EIP-155 chain ID
used for replay-protected transaction signing.
This method takes no parameters and is available on every tier
(polygon_read_rpc).
Parameters
This method takes no parameters.
——optional[] as params.Response
Response fields
| Field | Type | Description |
|---|---|---|
result | string | Network ID as a decimal string. "137" is Polygon mainnet. |
Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The API key's trial period has ended; upgrade to a paid tier to continue. |
-32002 | tier_insufficient | Your tier does not include the polygon_read_rpc scope. |
-32003 | rate_limited | You exceeded the requests-per-second limit for your tier. Back off and retry. |
-32004 | subscription_expired | The subscription tied to the API key has lapsed. |
-32005 | unauthorized | Missing or invalid API key. |
-32601 | method_unknown | The method is not available on the resolved upstream for your request. |
Errors are returned in the standard JSON-RPC envelope. See the shared errors reference for the full error object shape and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/polygon", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "net_version",
params: [],
}),
});
const { result } = await res.json();
console.log(result); // "137"
console.log(Number(result)); // 137TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const networkId = await client.polygon.rpc<string>("net_version", []);
console.log(networkId); // "137"
console.log(Number(networkId)); // 137Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
network_id = client.polygon.rpc("net_version", [])
print(network_id) # "137"
print(int(network_id)) # 137Notes
- The result is a decimal string, not a hex quantity — convert with
Number(result)(JS) orint(result)(Python). This differs frometh_chainId, which returns the hex quantity0x89. - The network ID is stable for the lifetime of the chain and never changes between blocks, so the value is safe to cache for the duration of a session.
- Polygon Amoy testnet returns
"80002". - Related:
eth_chainIdis the preferred chain-detection method for modern clients;net_listeningandnet_peerCountcover the rest of thenetnamespace.