Skip to main content

getEvents

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
fromBlockstringStarting block of the query
toBlockstringEnding block for the query
fromAddress stringThe address of the contract emitting the events
eventNameKeysarray<String>Array of strings
pageSizenumberNumber of records to be retrieved on one page
pageKeystring

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
countnumber Number of records returned in the current page
nextPageKeystring

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

eventsarray<object>The array of event objects
blockHashstringThe block hash that the event is in
blockNumbernumberThe block number that the event is in
blockTimestampstringThe timestamp in seconds for when the events was emitted
transactionHashstringThe transaction hash that the event is in
transactionIndexnumberThe index of the transaction
eventIndexnumberThe event index
fromAddressstringThe address of the contract emitting the events
keysarrayThe event's keys
dataarrayThe 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.

info

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/getEvents?fromBlock=501767 -H 'Content-Type: application/json'