question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a Ethers.js equivalent of web3-eth-contract.getpastevents?

See original GitHub issue

I can see how I can get new events with contract.events.onvaluechanged. But I want to get all the events from a block number

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
naddison36commented, Mar 5, 2018

As of version 3.0.1, the first line in the previous comment needs to change to

const IssueEvent = this.contract.interface.events.Issue;

Hopefully this helps anyone new to the library who wants to get past events.

5reactions
GFJHoguecommented, Oct 30, 2017

Here is how you get the topics for the Transfer event in your contract:

var Transfer = this.contract.interface.events.Transfer();

this.eventsProvider.getLogs({
  fromBlock: fromBlock,
  toBlock: "latest",
  address: this.contract.address,
  topics: Transfer.topics
})  // ...

See the Events example here: https://docs.ethers.io/ethers.js/html/api-advanced.html#id3

Read more comments on GitHub >

github_iconTop Results From Across the Web

web3.eth.Contract — web3.js 1.0.0 documentation
The web3.eth.Contract object makes it easy to interact with smart contracts on the ethereum blockchain. When you create a new contract object you...
Read more >
web3: How do I get past events of myContract.myEvent?
Seeing as there isn't a detailed updated answer: As @pors mentioned, web3.js has a getPastEvents function. You can have it run at startup,...
Read more >
Documentation - Ethers.js
A Contract is an abstraction of program code which lives on the Ethereum blockchain. The Contract object makes it easier to use an...
Read more >
Web3.js vs Ethers.js: Which is best? - YouTube
Become an in-demand blockchain MASTER:https://dappuniversity.com/bootcampEthers. js Tutorial: ...
Read more >
Using web3.js 'getPastEvents' to get specific events filtered by ...
This article focuses using the web3.js getPastEvents method with ... const contract = new web3.eth.Contract(contractAbi, contractAddress);
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found