0 votes
1 view
in Blockchain by (11.4k points)

What is the difference between using myContract.getPastEvents() to get past events and using myContract.events.MyEvent({ fromBlock: 0, }) ?

Also, if I pass to fromBlock a block number that has not been mined yet, does it work as expected?

1 Answer

0 votes
by (27.7k points)

 In general, MyEvent lets you specify filters within a specific event type (you can filter by parameter values), whereas getPastEvents returns all events for an event type.
 
getPastEvents will return all events that have occurred up until the block number the node you’re connected to is synced to.

MyEvent will return those same events, plus will call the callback on any new events that occur as new blocks are added to the chain.

hope this makes things little more clear 

...