TriportRPC

eth_blockNumber

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

Returns the latest Polygon block number as a hex-encoded string.

Polygonpolygon_read_rpcFree and up — free 15 rps · basic 20 rps · pro 100 rps · business 250 rps

eth_blockNumber returns the height of the latest block at the tip of the Polygon chain. The value is a string containing a 0x-prefixed hexadecimal integer (e.g. "0x3a1f2c0" = 60_815_552). It is the canonical way to discover the current chain tip before issuing range queries such as eth_getLogs, before computing confirmation depth for a transaction, or to drive a polling loop that watches for new blocks.

The method takes no parameters and is available on the free tier under the polygon_read_rpc scope, making it one of the cheapest calls you can issue. It reflects the chain tip as seen by the gateway; under normal conditions this is the canonical head, but during a reorg the returned height can briefly move backward, so treat any single value as the current best tip rather than a finalized height.

Polygon produces a block roughly every ~2.1 seconds. A client that needs to track the real-time tip should poll at a sub-block-time interval (e.g. every 1–1.5 s) so it does not miss blocks, while staying within the rps limit of its tier. For event-driven workflows that cannot tolerate polling latency, prefer a subscription-based channel over busy-polling this method.

Parameters

This method takes no parameters. Pass an empty params array.

_(none)_optional
params must be an empty array [].

Response

Response fields

FieldTypeDescription
jsonrpcstringJSON-RPC protocol version, always "2.0".
idnumber | stringEchoes the id from the request.
resultstringThe latest block number (blockNumber) as a 0x-prefixed hex string. Parse with parseInt(result, 16) / int(result, 16).

Errors

Errors are returned in the standard JSON-RPC envelope under the error object ({ "code": <int>, "message": <string> }). See errors.md for the full error envelope and shared semantics.

CodeMeaningWhen it happens
-32001trial_expired (HTTP 401)The free trial window for the key has ended; upgrade to a paid tier to continue.
-32002tier_insufficient (HTTP 403)The key's tier is not entitled to this method. (eth_blockNumber is free-tier, so this normally only surfaces on disabled keys.)
-32003rate_limited (HTTP 429)Requests exceeded the per-second limit for the key's tier (free 15 · basic 20 · pro 100 · business 250 rps). Back off and retry.
-32004subscription_expired (HTTP 401)The paid subscription tied to the key has lapsed.
-32005unauthorized (HTTP 401)The Authorization credential is missing, malformed, or invalid.
-32601method_unknown (HTTP 403)The method name was misspelled or is not exposed on this network.

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: "eth_blockNumber",
    params: [],
  }),
});


const { result } = await res.json();
const blockNumber = parseInt(result, 16);
console.log(`Latest Polygon block: ${blockNumber}`);

TypeScript SDK (@triport/sdk)

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


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


const result = await client.polygon.rpc<string>("eth_blockNumber", []);
const blockNumber = parseInt(result, 16);
console.log(`Latest Polygon block: ${blockNumber}`);

Python (triport-sdk)

import os
from triport import Triport


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


result = client.polygon.rpc("eth_blockNumber", [])
block_number = int(result, 16)
print(f"Latest Polygon block: {block_number}")

Notes

  • Polling cadence: with a ~2.1 s block time, poll at sub-block-time intervals (≈1–1.5 s) to avoid missing blocks. Confirm your polling rate stays under your tier's rps ceiling, and prefer a subscription channel over tight polling when you need the lowest latency.
  • Reorgs: the returned height tracks the gateway's view of the tip and can move backward briefly during a reorg. For settlement decisions, wait for a confirmation depth appropriate to your risk tolerance rather than acting on the bare tip.
  • Hex encoding: the result is always a 0x-prefixed hex string, never a decimal number — convert before doing arithmetic.
  • Related methods: eth_getBlockByNumber to fetch a full block once you have its height, and eth_getLogs for log queries over a block range whose upper bound you derive from this call.