Docs

Get

Get a list of a specific event’s occurrences emitted from the contract during a specified time period.

Usage

Provide the name of the event, and an optional filter to define the time period to get events for.

// Define the shape of the event data
public struct MyEvent
{
public string from;
public string to;
public string tokenId;
}
// Get all emitted events
var data = await contract.events.Get<MyEvent>("eventName");

Configuration

structure (generic type)

The event data structure to deserialize into, i.e. what shape the event data should be in.

eventName

The name of the event to get logs for.

In Solidity, an event is triggered by the emit keyword.

// An example Solidity contract
emit Transfer(); // Triggering event

To listen to this event, use the name of the event as it appears in the contract.

var data = await contract.events.Get<MyEvent>("Transfer");

filters (optional)

An optional object containing the fromBlock and toBlock numbers for the time period to get events for.

The order field indicates the ordering of the events; desc (descending) or asc (ascending).

The filters field allows you to filter on indexed event parameters.

The default fromBlock is 0 and the default toBlock is latest.

var data = await contract.events.Get<MyEvent>("eventName", new EventQueryOptions()
{
fromBlock = 0,
toBlock = 1000000,
order = "desc",
})