eth_getBlockByNumber
https://api.triport.io/polygonReturns a single Polygon block selected by block number or a named tag, optionally with every transaction body inlined.
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"0x3b9aca00") or a tag: latest, earliest, pending, safe, or finalized.fullTxBodiesbooleanrequiredfalse → transactions is an array of tx hashes (light). true → transactions 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)null for a pending block.hashstringnull for a pending block.parentHashstringnoncestring (hex)0x00…0 on Bor.sha3UnclesstringlogsBloomstringtransactionsRootstringstateRootstringreceiptsRootstringminerstringdifficultystring (hex)totalDifficultystring (hex)extraDatastringsizestring (hex)gasLimitstring (hex)gasUsedstring (hex)baseFeePerGasstring (hex)timestampstring (hex)unclesarray[] on Polygon (Bor consensus).transactionsarrayfullTxBodies=false; full tx objects when true.Errors
Errors arrive in the standard JSON-RPC error object; the extra fields move
into error.data.
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The free 7-day trial has ended. |
-32002 | tier_insufficient | Your tier is below what the method requires. (Not expected here — this method is free-tier.) |
-32003 | rate_limited | You exceeded the sustained rps for your tier; respect Retry-After / data.retry_after_sec. |
-32004 | subscription_expired | A previously active paid subscription has lapsed. |
-32005 | unauthorized | Missing, invalid, or revoked credentials. |
-32601 | method_unknown | The 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=falseis ~3–5 KB;trueis ~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.
unclesis always[]andsha3Unclesis 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.