eth_getBlockByHash
https://api.triport.io/v1/ethereumReturns a block, addressed by its 32-byte block hash, with its transactions either fully expanded or as a list of hashes.
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
Positional params array: [blockHash, fullTransactions].
blockHashstring (32-byte hex)required0x-prefixed (66 characters total).fullTransactionsbooleanrequiredtrue returns full transaction objects in transactions; false returns only transaction hashes.Response
With fullTransactions = false, transactions is an array of hashes:
When fullTransactions = true, each entry in transactions is a full
transaction object instead of a hash:
"transactions": [
{
"hash": "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
"blockHash": "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
"blockNumber": "0xf4629",
"transactionIndex": "0x0",
"from": "0xa1e4380a3b1f749673e270229993ee55f35663b4",
"to": "0x5df9b87991262f6ba471f09758cde1c0fc1de734",
"value": "0x7f110",
"gas": "0x4cb26",
"gasPrice": "0x2d79883d2000",
"nonce": "0x15",
"input": "0x"
}
]numberstring (hex)hashstring (hex)blockHash.parentHashstring (hex)noncestring (hex)sha3Unclesstring (hex)logsBloomstring (hex)transactionsRootstring (hex)stateRootstring (hex)receiptsRootstring (hex)minerstring (hex)difficultystring (hex)totalDifficultystring (hex)extraDatastring (hex)sizestring (hex)gasLimitstring (hex)gasUsedstring (hex)baseFeePerGasstring (hex)timestampstring (hex)transactionsarrayfullTransactions = false) or full transaction objects (when true).unclesarrayErrors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The API key's trial period has ended; upgrade to a paid tier to continue. |
-32003 | rate_limited | Per-tier RPS limit exceeded (10 / 20 / 100 / 250 RPS for free / basic / pro / business). Back off and retry after retry_after_sec. |
-32602 | Invalid params | blockHash is not a 32-byte hex string, or fullTransactions is missing or not a boolean. |
A non-existent block hash is not an error — the call returns result: null.
Every error follows the shared JSON-RPC error envelope — see
Errors for the full structure 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_getBlockByHash",
params: [
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
false,
],
}),
});
const { result: block } = await res.json();
if (block === null) {
console.log("no such block");
} else {
console.log(`block #${BigInt(block.number)} — ${block.transactions.length} txs`);
}TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const triport = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const block = await triport.ethereum.getBlockByHash(
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
false, // transaction hashes only; pass true for full objects
);
if (block) {
console.log(`block #${BigInt(block.number)} — ${block.transactions.length} txs`);
}Python (triport-sdk)
import os
from triport import Triport
triport = Triport(api_key=os.environ["TRIPORT_API_KEY"])
block = triport.ethereum.get_block_by_hash(
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
full_transactions=False,
)
if block is not None:
print(f"block #{int(block['number'], 16)} — {len(block['transactions'])} txs")Notes
nullmeans not found. Unknown hashes returnresult: null, not an error. Guard for it before reading any field.- Hashes are reorg-stable. A block hash identifies exactly one block, so lookups by hash are unaffected by chain reorganizations — unlike lookups by block number.
- Pick the cheaper transaction form. Use
fullTransactions = falsewhen you only need transaction IDs; it avoids transferring every transaction body. Passtrueonly when you need the inlined transaction objects. - Related methods:
eth_getBlockByNumber,eth_getBlockTransactionCountByHash,eth_blockNumber.