Skip to content

Listening for Future Events #1504

@hyndsite

Description

@hyndsite

The closed issue here talks about how to obtain future events as @mrwillis previous example of getting only future events, does produce events from the past as well.

//provides events at least as far back as current block (which is not future)
const filter = contract.filters.MyEmittedEvent(arg1, arg2);
contract.on(filter, callback);

@ricmoo has pointed out a poll approach using queryFilter, but if we want to subscribe to events, and only get for future events, I don't see there is way to do that with contract.on() - is that correct? queryFilter is only going to allow for a polling approach as opposed to being notified on an emitted Solidity event.

The only way I have found for this to work, is to get the current block number getBlockNumber and check on every fired event that I am subscribed to contract.on(filter, callback)) and react to only block number above the current block number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions