TriportRPC

net_version

POSThttps://api.triport.io/v1/polygon

Returns the network ID as a decimal string — `"137"` for Polygon mainnet.

Polygonpolygon_read_rpcfree — 15 RPS · basic — 20 RPS · pro — 100 RPS · business — 250 RPS

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
Pass an empty array [] as params.

Response

Response fields

FieldTypeDescription
resultstringNetwork ID as a decimal string. "137" is Polygon mainnet.

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
-32002tier_insufficientYour tier does not include the polygon_read_rpc scope.
-32003rate_limitedYou exceeded the requests-per-second limit for your tier. Back off and retry.
-32004subscription_expiredThe subscription tied to the API key has lapsed.
-32005unauthorizedMissing or invalid API key.
-32601method_unknownThe 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));      // 137

TypeScript 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));   // 137

Python (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))    # 137

Notes

  • The result is a decimal string, not a hex quantity — convert with Number(result) (JS) or int(result) (Python). This differs from eth_chainId, which returns the hex quantity 0x89.
  • 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_chainId is the preferred chain-detection method for modern clients; net_listening and net_peerCount cover the rest of the net namespace.