TriportRPC

eth_getBlockByNumber

Last updated:

`eth_getBlockByNumber` returns the full block object for a given block, identified either by a `0x`-prefixed hexadecimal block number or by one of the supported named tags. It is the standard way to read a historical or current block, including its header fields and its list of transactions.

The second parameter controls how much transaction detail comes back. When `fullTransactions` is `false`, the `transactions` array contains only transaction hashes (cheaper, smaller payload). When it is `true`, the array contains the fully expanded transaction objects for every transaction in the block.

If no block matches the requested number or tag — for example a height that has not been produced yet — the method returns `null` rather than an error. Always handle the `null` case before reading fields off the result.

Parameters

This method takes no parameters.

Returns

eth_getBlockByNumber return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "eth_getBlockByNumber",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getBlockByNumber","params":[],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. Credit cost: 1 per call.

FAQ

What does eth_getBlockByNumber do?
Returns information about a block on the Ethereum chain, selected by block number or by a named block tag.
How many credits does eth_getBlockByNumber cost?
eth_getBlockByNumber costs 1 credit(s) per call on Triport by default.
Is eth_getBlockByNumber available over WebSocket?
eth_getBlockByNumber is an HTTP JSON-RPC method.