getAllEvents
Get a list of all the events emitted from the contract during a specified time period.
Usage
By default, the method gets all events from block 0
to the latest block, in descending order.
const events = await contract.events.getAllEvents();
Configuration
filters (optional)
An 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 default fromBlock
is 0
and the default toBlock
is latest
.
const filters = {
fromBlock: 0,
toBlock: 1000000,
order: "desc",
};
const events = await contract.events.getAllEvents(filters);
Return Value
Returns an array of ContractEvent
objects, containing the following properties:
{
eventName: string;
data: TEvent;
transaction: {
blockNumber: number;
blockHash: string;
transactionIndex: number;
removed: boolean;
address: string;
data: string;
topics: Array<string>;
transactionHash: string;
logIndex: number;
}
}
[];