Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Is it possible to fetch contract’s previously triggered events? #1162

Open
avatar-lavventura opened this issue Jul 24, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@avatar-lavventura
Copy link
Contributor

avatar-lavventura commented Jul 24, 2021

Overview

  • What you are trying to do:
    I am trying to fetch the previously deployed transactions' events.

  • Why Brownie's current functionality is inadequate to address your goal
    Brownie is able to fetch the event data from the transaction object not from previously deployed transactions.


Here, we can fetch only the latest deployed transaction event data, if we have the tx object.

>>> tx
<Transaction object '0xa7616a96ef571f1791586f570017b37f4db9decb1a5f7888299a035653e8b44b'>
>>> tx.events[1].name

Can we also fetch the related contract function’s previously triggered events.

We can do it using web3.py, as follows:

contract = w3.eth.contract(contract_address, abi=abi)
block_read_from = 1000
event_filter = contract.events.MyEvent.createFilter(
    fromBlock=int(block_read_from), toBlock=int(block_read_from) + 1
)
events = event_filter.get_all_entries()

Would it be possible to integrate this approach into eth-brownie? or have a wrapper function for this?

@iamdefinitelyahuman
Copy link
Member

Yes, this would be very useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants