Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Contract events does not support fromBlock property #5201

@nazarhussain

Description

@nazarhussain

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Following two code snippets behaves exactly the same:

myContract.events.MyEvent({fromBlock: 0})
myContract.events.MyEvent()

Expected Behavior

If one subscribe for the events with fromBlock it should get the past logs with getPastEvents and emit those.

myContract.events.MyEvent({fromBlock: 0})

Steps to Reproduce

Following snippet should emit the two events which were triggered in the past.

myContract.methods.fireStrintEvent('event1'); 
myContract.methods.fireStrintEvent('event2'); 

(await myContract.events.MyEvent({fromBlock: 0})).on('data', console.log));

Web3.js Version

4.x

Environment

  • Operating System:
  • Browser:
  • Node.js Version:
  • NPM Version:

Anything Else?

This behavior can be implemented with combination of getPastEvents inside the event subscriber.

Metadata

Metadata

Labels

4.x4.0 relatedBugAddressing a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions