For example, I have an event where using clusterAddress as key, I want to find the other arguments (storageID, desc, etc.), only having the clusterAddress indexed.

I added the indexed keyword for the clusterAddress argument.

event LogJob(address indexed clusterAddress,
             string jobKey,
             uint index,
             uint8 storageID,        
             string desc

Later, should the following approach work under Web3.py (following this answer) or should I do something else to capture the indexed argument variable using Web3.py?

   def print_message(received_message): #{

   blockReadFrom = 1899690;
   myFilter = eBlocBroker.events.LogJob.createFilter(
       argument_filters={'clusterAddress': '0x4e4a0750350796164D8DefC442a712B7557BF282'}

  received_messages = []
  myFilter.watch(print_message) # Error occurs: AttributeError: 'LogFilter' object has no attribute 'watch'

Overall, I want to filter all the events using web3.py by passing the indexed argument. When I try to watch the LogFilter (like Watch callback return value Web3.js); I have receive following error: AttributeError: 'LogFilter' object has no attribute 'watch'

=> How to get all the events with the passed argument? After that if possible how could I watch the upcoming new emitted events?

  • can you share what problem are you facing with this snippet? Commented Jul 25, 2018 at 7:31
  • I just wanted to double check my approach is correct. Please also see my updated question: I am not able to watch the filter I have created. @HarshVakharia
    – alper
    Commented Jul 25, 2018 at 8:06
  • I have updated my answer! Commented Jul 26, 2018 at 11:03
  • Is there any alternative for watch() function? @Harsh Vakharia
    – alper
    Commented Jul 26, 2018 at 11:08

1 Answer 1


EDIT: Regarding the watch method, it has been removed from v4. So except last 2 lines, your code should just work for v4.

From the snippet of your smart contract, you can filter events using clusterAddress just like you have in your code snippet.

Make sure you are setting right fromBlock and the event you are filtering for should occur after that block.

  • Thanks! So there’s no way with web3.py to listen to events other than setting up a loop with a fixed polling interval? Commented Jan 29, 2022 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.