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