0

Does infura or alchemy have the capability to listen to each and every filter of a contract on one node?

I want to listen to about 6 events all at once from a lending pool.

I'm using web3py like this:

def log_loop(event_filter, poll_interval):
    while True:
        for event in event_filter.get_new_entries():
            handle_event(event)
        time.sleep(poll_interval)

def main():
    event_filter = contract.events.Deposit.createFilter(fromBlock="latest", argument_filters={})
    worker = Thread(target=log_loop, args=(event_filter, 5), daemon=True)

    worker.start()

I want to do something like (this isn't actual working code):

def log_loop(event_filter, poll_interval):

    while True:
        for event_filter in event_filters:
            for event in event_filter.get_new_entries():
                handle_event(event)
            time.sleep(poll_interval)

def main():
    event_filter = contract.events(fromBlock="latest", argument_filters={})

    worker = Thread(target=log_loop, args=(event_filter, 5), daemon=True)

    worker.start()

I also should mention i really want to avoid making 6 threads to accomplish this or use background jobs.

I'm tagging web3js because I believe that the community is bigger and may be able to help out.

I don't want to filter each specific event. I would rather just listen to each event and query the results from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.