eth_blockNumber
https://api.triport.io/v1/ethereumReturns the number of the most recent block on the Ethereum chain.
eth_blockNumber returns the index of the latest block the node has seen,
encoded as a 0x-prefixed hexadecimal string. It takes no parameters and is the
canonical way to learn the current chain head.
Use it to track chain progress, to pick a concrete latest block height before
issuing a batch of historical reads, or as a lightweight liveness/health probe
against the RPC endpoint. The value advances roughly once every ~12 seconds on
Ethereum mainnet.
Because the result is hex, remember to convert it before using it as a decimal
number — e.g. parseInt("0x149e2c1", 16) → 21619905.
Parameters
This method takes no parameters; pass an empty array.
_(none)_arrayrequired[].Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version, always "2.0". |
id | number | Echoes the request id. |
result | string | Latest block number as a 0x-prefixed hex string (e.g. 0x149e2c1 = 21619905). |
Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The account's trial period has ended. |
-32002 | tier_insufficient | The account's tier does not grant access to this method. |
-32003 | rate_limited | The per-tier RPS limit was exceeded. Back off and retry. |
-32004 | subscription_expired | The account's paid subscription has lapsed. |
-32005 | unauthorized | Missing or invalid API key. |
-32601 | method_unknown | The method name is not recognized. |
See errors.md for the full error envelope 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: "eth_blockNumber",
params: [],
}),
});
const { result } = await res.json();
console.log("latest block:", parseInt(result, 16)); // 21619905TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const result = await client.ethereum.request<string>("eth_blockNumber", []);
console.log("latest block:", parseInt(result, 16));Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
result = client.ethereum.request("eth_blockNumber", [])
print("latest block:", int(result, 16))Notes
- The result is a hex string, not a number — convert with base 16 before arithmetic.
eth_blockNumberis available on the free tier (eth_read_rpccategory).- Rate limiting is RPS-per-tier with burst; there is no daily quota. A
-32003 rate_limitederror means you should back off and retry shortly. - To fetch the block itself, follow up with
eth_getBlockByNumber. To read the current gas price alongside the head, seeeth_gasPrice.