getBlock
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
Field | Type | Description |
---|---|---|
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
Field | Type | Description |
---|---|---|
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!
Curl Request example
curl -X GET https://starknet-mainnet.blastapi.io/<project-id>/builder/getBlock?blockNumberOrHash=501652 -H 'Content-Type: application/json'