getBlock -SDK

Returns the block from the network based on the provided block number or hash.

Don’t have an API key?

Start using this method in your app today.


Returns the block from the network based on the provided block number or hash. Transactions on the block are represented as an array of transaction hashes. To get the full transaction details on the block, use getBlockWithTransactions instead.


blockHashOrBlockTagstringThe block number or hash to get the block for.


Promise<Block>objectReturns a block object with the following fields or null when no block was found.

Block response object parameters

hashstring32 Bytes - hash of the block. null when its pending block.
parentHashstring32 Bytes - hash of the parent block.
numbernumberThe block number. null when its pending block.
timestampnumberThe unix timestamp for when the block was collated.
noncestringA nonce is a value that represents the number of transactions sent by the sender's address, ensuring the transactions are processed in order and preventing replay attacks.
difficultynumberInteger of the difficulty for this block.
gasLimitBigNumberThe maximum gas allowed in this block.
gasUsedBigNumberThe total used gas by all transactions in this block.
minerstring20 Bytes - the address of the beneficiary to whom the mining rewards were given.
transactionsarrayAn arrray containing transactions.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

npm install alchemy-sdk
yarn add alchemy-sdk


Here is an example of how to make a getBlock request using the Alchemy SDK:

// Imports the Alchemy SDK
const { Alchemy, Network } = require("alchemy-sdk");

// Configures the Alchemy SDK
const config = {
    apiKey: "alchemy-replit", // Replace with your API key
    network: Network.ETH_MAINNET, // Replace with your network

// Creates an Alchemy object instance with the config to use for making requests
const alchemy = new Alchemy(config);

const main = async () => {
    //Assign the hash to a variable
    let txHash = "0x92fc42b9642023f2ee2e88094df80ce87e15d91afa812fef383e6e5cd96e2ed3"

    //Response would return the block for provided hash
    let response = await alchemy.core.getBlock(txHash)

    //Logging the response to the console



  hash: '0x92fc42b9642023f2ee2e88094df80ce87e15d91afa812fef383e6e5cd96e2ed3',
  parentHash: '0x6890edf8ad6900a5472c2a7ee3ef795f020ef6f907afb7f4ebf6a92d6aeb1804',
  number: 15221026,
  timestamp: 1658877717,
  nonce: '0xd8c399035d6e6e8f',
  difficulty: null,
  gasLimit: BigNumber { _hex: '0x01ca35d2', _isBigNumber: true },
  gasUsed: BigNumber { _hex: '0x01ca1ae1', _isBigNumber: true },
  miner: '0x52bc44d5378309EE2abF1539BF71dE1b7d7bE3b5',
  extraData: '0x6e616e6f706f6f6c2e6f7267',
  transactions: [
    ... 253 more items
  baseFeePerGas: BigNumber { _hex: '0x02aa2d1d80', _isBigNumber: true },
  _difficulty: BigNumber { _hex: '0x2a31d8a2cf4dd7', _isBigNumber: true }

Code Sandbox

You can test out the getBlock method using the code sandbox below:

Related Methods

Here are the methods related to getBlock:

  • getBlockWithTransactions: Returns the block from the network based on the provided block number or hash. Includes full transactions from the block.