Skip to content

Conversation

@ddallaire
Copy link

Description

Using get_logs becomes tedious when ingesting all of a contract events. This creates a way to ingest and decode all of the events emitted from a contract instance to reduce the need to get logs using multiple event filters.

Details

  • Adds a get_logs_for_contract function which receives all of a contract event filters along with an address
    • Returns the decoded events using Events. find_and_decode

Checklist

  • Create the get_logs_for_contract function using the same pattern as get_logs
  • Update technical documentation and README
  • Create unit tests to cover this feature

@ddallaire
Copy link
Author

@alisinabh Hey, love the library, I keep running into having to create a bunch of filters to ingest manually multiple events of the same contract, this aims to fix this, feel free to close it if you don't think it belongs here.

Add a way to fetch all contract events
@ddallaire ddallaire force-pushed the feat/get-contract-events branch from 5cbd5d0 to b5ee972 Compare August 24, 2025 17:59
@ddallaire ddallaire force-pushed the feat/get-contract-events branch from b5ee972 to efecb06 Compare August 24, 2025 18:02
Copy link
Member

@alisinabh alisinabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition.

Upon first look I added one comment.

Also Im not sure a function in Ethers module is the best answer here. My initial thought is to have a function (maybe in Utils) that returns all event filters of a contract then the result of that can be used with the same get_logs function.

@ddallaire
Copy link
Author

ddallaire commented Aug 25, 2025

Thanks for the addition.

Upon first look I added one comment.

Also Im not sure a function in Ethers module is the best answer here. My initial thought is to have a function (maybe in Utils) that returns all event filters of a contract then the result of that can be used with the same get_logs function.

That sounds reasonable, could adapt the get_logs function to allow for multiple event filters, something like:

def get_logs(event_filters, overrides \\ []) when is_list(event_filters)

Or allow a list in the same function and have pre_process handle lists to split by topics.

Let me know what you think.

@alisinabh
Copy link
Member

Yeah I think pre_process/4 should handle that, the get_logs function just needs its documentation and spec and variable naming changes.

One caveat is that we should ensure that if there are more than one event filter with a default address they must be the same. Otherwise we should require an explicit address field as eth_getLogs does not support multiple addresses AFAIK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants