TriportRPC

net_version

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

Returns the current network ID as a decimal string (for example `"1"` for Ethereum mainnet).

Ethereumeth_read_rpcfree — 10 RPS · basic — 20 RPS · pro — 100 RPS · business — 250 RPS

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.

optional
Pass an empty array [] as params.

Response

Response fields

FieldTypeDescription
resultstringThe network ID as a decimal string. "1" is Ethereum mainnet.

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
-32003rate_limitedYou exceeded the requests-per-second limit for your tier. Back off and retry.

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/ethereum", {
  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);              // "1"
console.log(parseInt(result, 10)); // 1

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


const networkId = await client.ethereum.rpc<string>("net_version", []);
console.log(networkId);               // "1"
console.log(parseInt(networkId, 10)); // 1

Python (triport-sdk)

import os
from triport import Triport


client = Triport(api_key=os.environ["TRIPORT_API_KEY"])


network_id = client.ethereum.rpc("net_version", [])
print(network_id)        # "1"
print(int(network_id))   # 1

Notes

  • The result is a decimal string — parse it with parseInt(result, 10) (JS) or int(result) (Python), not base 16.
  • The network ID is stable for the lifetime of a network, so the value is safe to cache for the duration of a session.
  • Related: use eth_chainId for the EIP-155 chain ID as a hex quantity (the value you need when signing transactions), and eth_blockNumber to read the current head once you have confirmed the network.