getEvents

Get all events matching the given filters

Efficiently access and analyze blockchain events with the getEvents method, designed to retrieve events that match your specified filters. Our documentation offers comprehensive insights into using the getEvents method, empowering developers to efficiently access and analyze blockchain events. This method API presents returns items in descending order by both blockNumber and eventIndex

How to use getEvents method ?

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

Parameters

Below, you can find the query parameters accepted by the method.

FieldTypeDescription

fromBlock

string

Starting block of the query

toBlock

string

Ending block for the query

fromAddress

string

The address of the contract emitting the events

eventNameKeys

array<String>

Array of strings

pageSize

number

Number of records to be retrieved on one page

pageKey

string

Key used to get the next page of results. Must be set to the value of nextPageKey returned in the previous response

Returns

Discover an insightful explanation of the returned parameters here, offering a deep understanding of their significance and implications.

FieldTypeDescription

count

number

Number of records returned in the current page

nextPageKey

string

Key to get the next page of results, if more results are available

events

array<object>

The array of event objects

blockHash

string

The block hash that the event is in

blockNumber

number

The block number that the event is in

blockTimestamp

string

The timestamp in seconds for when the events was emitted

transactionHash

string

The transaction hash that the event is in

transactionIndex

number

The index of the transaction

eventIndex

number

The event index

fromAddress

string

The address of the contract emitting the events

keys

array

The event's keys

data

array

The event's data

Example Request and Result for getEvents

In this section, you'll find an illustrative example showcasing the use of the getEvents method. We provide a request and its corresponding result to help you understand how to effectively retrieve and interpret blockchain events that match your specified filters, using this powerful API.

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!

Get all events matching the given filters

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

Query Parameters

NameTypeDescription

fromBlock

String

501767

{
"count":100
"nextPageKey":"MThhODk4MWE4ZDBhOjE3MDQ5MDI4NTA6NTAxNzY4OjQ2NA"
"events":[
0:{
"blockHash":"0x043ee630e834817b76cefcfec3dd75f538618bca267dfff1…"
"blockNumber":501768
"blockTimestamp":"2024-01-10T15:35:25.000Z"
"transactionHash":"0x0301e2f6fa4428345d3294f848f747aca57ee3d5adb64089…"
"transactionIndex":93
"eventIndex":563
"fromAddress":"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b…"
"keys":[]
"data":[]
}
...

Curl request example

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

Last updated