TriportRPC

eth_getBlockByHash

Last updated:

`eth_getBlockByHash` looks up a single block by its hash and returns the full block header plus its transaction list. Use it when you already hold a block hash — for example from a log, a receipt's `blockHash`, or a previous `eth_getBlockByNumber` response — and want the canonical block it identifies. Looking up by hash is unambiguous across reorgs: a hash pins exactly one block, whereas a block *number* can be reassigned to a different block after a reorganization.

The second parameter controls how transactions are returned. Pass `true` to get each transaction inlined as a full object (sender, recipient, value, input data, gas, etc.); pass `false` to get just the array of transaction hashes, which is cheaper to transfer when you only need the IDs.

If no block with the given hash is known to the node, the call succeeds and returns `null` rather than an error — always check for `null` before reading fields off the result.

Parameters

This method takes no parameters.

Returns

eth_getBlockByHash return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByHash","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "eth_getBlockByHash",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getBlockByHash","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_getBlockByHash do?
Returns a block, addressed by its 32-byte block hash, with its transactions either fully expanded or as a list of hashes.
How many credits does eth_getBlockByHash cost?
eth_getBlockByHash costs 1 credit(s) per call on Triport by default.
Is eth_getBlockByHash available over WebSocket?
eth_getBlockByHash is an HTTP JSON-RPC method.