eth_getBlockByHash

Ethereum RPC

Overview

The eth_getBlockByHash is an Ethereum JSON-RPC method that allows developers to query a specific block in the Ethereum blockchain by its block hash. This method can be used in various scenarios, such as analysing historical transactions, validating the state of the blockchain, or monitoring the progress of mining activities.

Parameters

The eth_getBlockByHash method accepts two parameters:

  1. blockHash: The hash of the block you want to retrieve information about.
    • Type: String
    • Example: "0x75e58e08a9f3a23bac9788d5077a9365abb5c29ec1aab70891264051624720af"
  2. fullTransactionDetails: A boolean value indicating whether to return full transaction details or just transaction hashes.
    • Type: Boolean
    • Example: True

Returns

The response from the eth_getBlockByHash method is a JSON object containing the following fields:

NameDescription
numberThe block number (hexadecimal string).
hashThe block hash (32-byte string).
parentHashThe hash of the parent block (32-byte string).
nonceThe nonce used to generate the block (8-byte string).
sha3UnclesThe SHA3 hash of the uncles in the block (32-byte string).
logsBloomThe logs bloom filter of the block (256-byte string).
transactionsRootThe root of the transaction trie (32-byte string).
stateRootThe root of the state trie (32-byte string).
minerThe address of the miner who mined the block (20-byte string).
difficultyThe difficulty of the block (hexadecimal string).
totalDifficultyThe total difficulty of the chain up to this block (hexadecimal string).
extraDataExtra data included by the miner in the block (byte string).
sizeThe block size in bytes (hexadecimal string).
gasLimitThe gas limit for the block (hexadecimal string).
gasUsedThe total gas used by all transactions in the block (hexadecimal string).
timestampThe block timestamp (hexadecimal string).
transactionsAn array of transaction objects or transaction hashes, depending on the returnFullTransactionObjects parameter.
unclesAn array of uncle block hashes (32-byte strings).

If returnFullTransactionObjects is true, the transactions field contains transaction objects with the following fields:

NameDescription
hashThe block hash (32-byte string).
nonceThe nonce used to generate the block (8-byte string).
blockHashThe block hash where the transaction is included (32-byte string).
blockNumberThe block number where the transaction is included (hexadecimal string).
transactionIndexThe index of the transaction in the block (hexadecimal string).
fromThe sender address (20-byte string).
toThe recipient address, or null for contract creation transactions (20-byte string).
valueThe value being transferred (hexadecimal string).
gasPriceThe gas price in wei (hexadecimal string).
gasThe gas provided for the transaction (hexadecimal string)..
inputThe input data for the transaction (byte string).

Request

curl --location 'https://api.tatum.io/v3/blockchain/node/ethereum-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByHash",
  "params": ["0x75e58e08a9f3a23bac9788d5077a9365abb5c29ec1aab70891264051624720af", true],
  "id": 1
}'
// yarn add @tatumio/tatum

import { TatumSDK, Ethereum, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const block = await tatum.rpc.getBlockByHash(
  '0x75e58e08a9f3a23bac9788d5077a9365abb5c29ec1aab70891264051624720af',
  true,
)

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs