L0vdL0vd

eth_getBlockByHash

Returns a block by hash.

Archive · Works on any past block

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByHash","params":["0xc7a2fd354a9a1512636dad41b44e618905f5e8d2500f08c515c3bbbdf5261f6a",false]}'

Example response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "baseFeePerGas": "0x2c35b23c2",
    "difficulty": "0x0",
    "extraData": "0x4070656e6775696e6275696c642e6f7267",
    "gasLimit": "0x1c9c380",
    "gasUsed": "0xbe79ac",
    "hash": "0xc7a2fd354a9a1512636dad41b44e618905f5e8d2500f08c515c3bbbdf5261f6a",
    "logsBloom": "0x3525911ae0613375a2aa18f5863ab32838800fbddd5564c40d91621b9443135d749b2482eab0206c424c112c0e0041c72643c45ca801349d1789911101fee4004640641b107a0d7b68b0e34ddfa418a9544d119114c25e1664c1a427f87021a083e656cb…",
    "miner": "0xf15689636571dba322b48e9ec9ba6cfb3df818e1",
    "mixHash": "0x2813591c7fa6b60650d52a8258ac2a3e5f0d8b74b7fcf68820ad9525a54a1191",
    "nonce": "0x0000000000000000",
    "number": "0x1208a5f",
    "parentHash": "0xaa54d34d62525835280b02fc9662e022877698aadcd9a1e4644283d1ea32d206",
    "receiptsRoot": "0x02d59348a2e0d99bbe8489ef73ec56dad9f4d72b1fbcbe51beb314aa027f6102",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0xbe3d",
    "stateRoot": "0x68b96e88aca3010c517d787e5a0d94ada8bc5795cba44c45fa67b2e0c8f52e54",
    "timestamp": "0x65922b33",
    "transactions": [
      "0xbb62ecfc053ce6aa2f12dd09261e27e7c06b46dd015c67e28d5f7200bd6251ac",
      "0xda13880bec0b648aa3bbc5b036811443b036314da24a537daf251cf659f7404c"
    ],
    "transactionsRoot": "0xa280fc3336bf21914c79d3acaf7736332576cc6059157c23bc4e04d6a47b264f",
    "uncles": [],
    "withdrawals": [
      {
        "index": "0x1c9b8e6",
        "validatorIndex": "0x34ca0",
        "address": "0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f",
        "amount": "0x10cf12e"
      },
      {
        "index": "0x1c9b8e7",
        "validatorIndex": "0x34ca1",
        "address": "0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f",
        "amount": "0x10c527d"
      }
    ],
    "withdrawalsRoot": "0x7e4da59cfd250ceb7727e2e6194754f6ea6b63c69bd2b18a5e97135cd177f852"
  }
}

Long arrays and hex strings are shortened in this example.

Params and your endpoint

Parameters

blockHashstringrequired
32-byte block hash.
fullTransactionsbooleanrequired
true returns full transaction objects, false only their hashes.

Returns

object Block object, or null.

numberstring
Block number, hex.
hashstring
Block hash.
parentHashstring
Hash of the parent block.
timestampstring
Unix timestamp, hex.
minerstring
Fee recipient address.
gasUsedstring
Total gas used by the block's transactions, hex.
gasLimitstring
Block gas limit, hex.
baseFeePerGasstring
EIP-1559 base fee, hex wei (London and later).
transactionsarray
Transaction hashes, or full transaction objects when the second parameter is true.
logsBloomstring
Bloom filter for the block's logs.
stateRootstring
Root of the state trie after the block.

When to use it

Read a block by its hash. Hashes are unique and never change, so this is safe to use while handling reorgs.

How to read the result

Same block object as eth_getBlockByNumber. null if the hash is unknown, for example a block that was reorged out long ago.

Tips

  • Store block hashes next to numbers in your index; on reorg, compare parentHash to detect where the chain diverged.

Related methods