I am trying to listen to events emitted from a contract using eth-brownie. More specifically I am attempting to use EventWatcher. My contract emit has an event eventI in it. My run.py file looks like,

from brownie.network.event import EventWatcher
from brownie import Contract, emit
def run():
    # get contract
    emit = Contract.from_abi( emit,
                              [contract adress], 
                              [contract abi])

    # start watcher

    # define callback function
    def watched():

    # use add_event_callback
def main():

I have two questions; 1) am I implementing the above arguments correctly? 2) when I run it I get the error,

EventWatcher.add_event_callback() missing 
1 required positional argument: 'self'

From running inspect.signature(EventWatcher.add_event_callback) I know self should be the first input, but I don't know what the form of it should be. I tried things like emit.self if that makes any sense...

1 Answer 1


Following asnwers to this question and also getting some clues from print(dir(EventWatcher)) I resolved the above error as follows,

start watcher:

    watch = EventWatcher()
    print(f'has started? {watch._has_started}')          # OUT: False
    print(f'has started? {watch._has_started}')          # OUT: True

add callback function:

    def watched(number):              # callback function
        print(f'{number} was watched.')

    print(f'targets:  {watch.target_events_watch_data}')        # OUT: {}
    addCallBack = watch.add_event_callback(event=emit.events["eventI"],
    print(f'targets:  {watch.target_events_watch_data}')  
              # OUT: {'[emit address]+eventI': <brownie.network.event.
                      _EventWatchData object at 0x000001A45B67EA10>}

Note that my event is defined as,

    event eventI(uint256 input);

notice that the callback function has a uint256 input as well (*clarify needeed; the two must match).

Really wish they'd give more detailed documentation on this function. EventWatcher seems to be some well-knonw function in javascript or other language, and its manifestation in brownie seems to presume everyone using it is familiar with its use in some other context.

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.