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
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/eth \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"eth_getBlockByHash","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/eth", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "eth_getBlockByHash",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/eth",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"eth_getBlockByHash","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- 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.