getBlock

Get the contents of a block

Efficiently access the contents of a block using either its block number or block hash as query parameters.

How to use getBlock method ?

Below, you'll find an in-depth guide that provides a comprehensive explanation of how to utilize the getBlock method effectively using Blast Builder API.

Parameters

FieldTypeDescription

blockNumberOrHash *

string

This parameter is essential and must be provided. Depending on the value you specify, whether it's the block height or block hash, it will initiate the retrieval of the block contents.

Result

FieldTypeDescription

blockHash

string

This represents the hash of the specified block

blockNumber

number

This represents the height of the specified block

blockTimestamp

string

The timestamp of the block

parentBlockHash

string

The hash that identifies the previous block in the chain

sequencerAddress

string

The sequencer address that constructed the block

stateRoot

string

The state commitment after this block

status

string

The status of the block

totalActualFee

string

The gas fee the transaction paid

transactionCount

string

The number of transactions in the specified block

eventCount

number

The number of events

messageCount

string

The number of messages

Example Request and Result for getBlock

In this section, we provide an illustrative example of a request made to retrieve block contents using the getBlock Builder API method. Additionally, we present the resulting response containing information about the specified block. This example demonstrates how to interact with the API to obtain details about a specific block, including its hash, block number, timestamp, and various other attributes. Developers can use this as a reference for crafting their own requests and parsing the returned data when working with the getBlock Builder API method.

The example in this section uses a non-existing project id.

Make sure you replace it with your Starknet endpoint when issuing the Builder API calls.

Don't have a project id? Here's a straightforward guide on how to obtain one!

Return the contents of a block by blockNumber or blockHash

GET https://starknet-mainnet.blastapi.io/<project-id>/builder/getBlock?

Query Parameters

NameTypeDescription

blockNumberOrHash*

String

501652

{
  "blockHash": "0x05623571ff137d26b2dd9fd925f4e02cd88ec26bd45ac4e6f7ae738d4c055ba5",
  "blockNumber": 501652,
  "blockTimestamp": "2024-01-10T12:21:47.000Z",
  "parentBlockHash": "0x066261ca033ac76af17c499101a6b22b794f6c8bd5308bb2b20814d2599c0ccb",
  "sequencerAddress": "0x01176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
  "stateRoot": "0x0099360f339dd48fa77bdf66b2cbfb375a7de9de872798f7374e98e4e2639896",
  "status": "ACCEPTED_ON_L2",
  "totalActualFee": "28896563259679808",
  "transactionCount": 118,
  "eventCount": 794,
  "messageCount": 0
}

Curl Request example

curl -X GET https://starknet-mainnet.blastapi.io/<project-id>/builder/getBlock?blockNumberOrHash=501652 -H 'Content-Type: application/json'

Last updated