If I understand correctly, in web3.js the allevents method enables a contract event to be monitored.

is there an equivalent in python ?

  • 1
    Do you mean is there a Python based API similar to web3.js that can listen for events?
    – dbryson
    Apr 19 '16 at 23:46

If you want to do local testing of your contract, you can use PyEthereum's tester to capture and view events from your contract via the ABIContract class.

If you're looking for a Python based RPC client you may want to look at ethjsonrpc. It appears ethjsonrpc has support for event functions.


response to self but might be handy for others, there is a library called web3.py https://github.com/pipermerriam/web3.py that let you create filters (http://web3py.readthedocs.io/en/latest/filters.html)

you do it by creating a filter object, then you add a watch method to it that returns a callback function

def new_transaction_callback(transaction_hash):
    sys.stdout.write("New Block: {0}".format(transaction_hash))

new_transaction_filter = web3.eth.filter('pending')
  • new_transaction_filter does not have a method called watch() @euri10
    – alper
    Jun 25 '18 at 10:47
  • If you are using Infura than this won't work. You have to set up your own node Dec 17 '19 at 6:01

Your Answer

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

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