3

According to the Web3.py Documentation: http://web3py.readthedocs.io/en/latest/filters.html

event_filter = contract.events.myEvent.createFilter(fromBlock='latest', {'filter': {'arg1':10}})

                                                              ^

Then I got: "SyntaxError: positional argument follows keyword argument"

Then I removed "fromBlock='lastest',"

event_filter = contract.events.myEvent.createFilter({'filter': {'arg1':10}})

Then I got: "TypeError: createFilter() takes 1 positional argument but 2 were given"

Ok... then I Googled that... https://stackoverflow.com/questions/23944657/typeerror-method-takes-1-positional-argument-but-2-were-given

let's try: my_new_object = cInst.events()

Then I got "TypeError: 'ContractEvents' object is not callable"

Does this web3.py Documentation work at all??? I am so disappointed... :(

Please help. Thank you

1 Answer 1

5

You can use the following method in web3py to get events:

myfilter = mycontract.eventFilter('EventName', {'fromBlock': 0,'toBlock': 'latest'});
eventlist = myfilter.get_all_entries()

eventlist will be a list of dictionaries containing the parameters of each event that had happened.

Hope this helps.

7
  • Wow. Thank you Jaime. However I got this: "requests.exceptions.ReadTimeout: HTTPConnectionPool(host='room2.abc.com', port=8545): Read timed out. (read timeout=10) ". Could you suggest something? Thank you!
    – Russo
    May 28, 2018 at 7:43
  • This seems to be a problem with your node connection, are you running your own node?, be sure that you are actually connected to the network, let me know how it goes.
    – Jaime
    May 28, 2018 at 8:05
  • Jaime, you are absolutely correct. The node was down... Thank you!
    – Russo
    May 29, 2018 at 3:14
  • 1
    Jaime, I got it: event_list[idx].args.eventArgument1 !!! THANK YOU!
    – Russo
    May 30, 2018 at 5:11
  • How could I also add filter @Jaime ?
    – alper
    Jul 3, 2018 at 0:20

Your Answer

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

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