TriportRPC

eth_getBlockByNumber

POSThttps://api.triport.io/polygon

Returns a single Polygon block selected by block number or a named tag, optionally with every transaction body inlined.

Polygonpolygon_read_rpcfree (and up) — 15 rps (free) · 20 rps (basic) · 100 rps (pro) · 250 rps (business); burst = 2 × the sustained rps

eth_getBlockByNumber is the most common block read on Polygon. Given a block number (or one of the tags latest, earliest, pending, safe, finalized) it returns the block's header plus its transaction list. The second parameter chooses how transactions are rendered: pass false to get an array of transaction hashes (a light ~3–5 KB payload), or true to inline every full transaction body (a heavier ~30–100 KB payload for a typical block of 50–150 transactions).

Polygon's block time is roughly 2.1 seconds, so eth_getBlockByNumber("latest", …) advances about every 2 s. A bot tracking the chain tip in real time should poll on that cadence rather than tighter — there is no new block to fetch in between.

Polygon runs Bor consensus and therefore has no uncle blocks: the uncles array is always empty and sha3Uncles is the empty-list hash. This is the main shape difference from Ethereum mainnet. Use eth_getBlockByHash instead when you already hold a block hash (for example, to detect a re-org by checking whether a previously seen hash still resolves).

Parameters

Positional params array: [blockNumber, fullTxBodies].

blockNumberstringrequired
A hex-encoded block number (e.g. "0x3b9aca00") or a tag: latest, earliest, pending, safe, or finalized.
fullTxBodiesbooleanrequired
falsetransactions is an array of tx hashes (light). truetransactions holds full transaction objects (heavy).

Response

With fullTxBodies: true, each entry of transactions is a full transaction object (hash, from, to, value, input, gas, gasPrice, maxFeePerGas, nonce, blockNumber, transactionIndex, …) instead of a hash string.

If the requested block does not exist, result is null.

numberstring (hex)
Block number. null for a pending block.
hashstring
Block hash. null for a pending block.
parentHashstring
Hash of the parent block.
noncestring (hex)
PoW nonce; 0x00…0 on Bor.
sha3Unclesstring
Keccak-256 of the uncle list — always the empty-list hash on Polygon.
logsBloomstring
Bloom filter over the block's logs.
transactionsRootstring
Root of the transaction trie.
stateRootstring
Root of the final state trie.
receiptsRootstring
Root of the receipts trie.
minerstring
Address credited with producing the block.
difficultystring (hex)
Block difficulty.
totalDifficultystring (hex)
Cumulative chain difficulty up to this block.
extraDatastring
Extra data field set by the block producer.
sizestring (hex)
Block size in bytes.
gasLimitstring (hex)
Maximum gas allowed in the block.
gasUsedstring (hex)
Gas actually consumed by all transactions.
baseFeePerGasstring (hex)
EIP-1559 base fee per gas for this block.
timestampstring (hex)
Unix timestamp when the block was produced.
unclesarray
Uncle hashes — always [] on Polygon (Bor consensus).
transactionsarray
Tx hashes when fullTxBodies=false; full tx objects when true.

Errors

Errors arrive in the standard JSON-RPC error object; the extra fields move into error.data.

CodeMeaningWhen it happens
-32001trial_expiredThe free 7-day trial has ended.
-32002tier_insufficientYour tier is below what the method requires. (Not expected here — this method is free-tier.)
-32003rate_limitedYou exceeded the sustained rps for your tier; respect Retry-After / data.retry_after_sec.
-32004subscription_expiredA previously active paid subscription has lapsed.
-32005unauthorizedMissing, invalid, or revoked credentials.
-32601method_unknownThe method name was not recognised on the polygon chain.

See the shared Errors reference for the full envelope, the HTTP-status mapping, and error.data field definitions.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/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_getBlockByNumber",
    params: ["latest", false],
  }),
});


const { result, error } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log("tip block:", parseInt(result.number, 16), "tx count:", result.transactions.length);

TypeScript SDK (@triport/sdk)

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


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


// Light read: hashes only.
const block = await client.polygon.rpc("eth_getBlockByNumber", ["latest", false]);
console.log(Number(block.number), block.transactions.length);


// Heavy read: full transaction bodies.
const fullBlock = await client.polygon.rpc("eth_getBlockByNumber", ["latest", true]);

Python (triport-sdk)

import os
from triport import Triport


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


block = client.polygon.rpc("eth_getBlockByNumber", ["latest", False])
print(int(block["number"], 16), len(block["transactions"]))

Notes

  • Payload sizing. fullTxBodies=false is ~3–5 KB; true is ~30–100 KB for a typical 50–150-tx Polygon block. Fetch hashes first and pull only the bodies you need unless you genuinely require all of them.
  • Tip polling. With ~2.1 s block time, poll ["latest", false] about every 2 seconds for real-time tip tracking.
  • No uncles. uncles is always [] and sha3Uncles is the empty-list hash (Bor consensus). Do not write logic that expects uncle data on Polygon.
  • No daily cap. Rate limiting is sustained-rps-per-tier with a 2× burst allowance — there is no daily quota. See Rate limits.
  • Related: eth_getBlockByHash (same shape, by hash) · eth_getBlockReceipts (all receipts in a block in one call) · eth_getBlockTransactionCountByNumber.