Given a function and a event in a contract:

event OtherCreated(address other, address addr1, address addr2);

function doSomething(address addr1, address addr2){
     if(aBool == true){
        address other = new OtherContract(addr1, addr2);
        OtherCreated(other, addr1, addr2);

And given a js call in a browser:

      console.log('previous call completed');
     otherCreated = contractAddr.OtherCreated();
     otherCreated.watch(function(error, result){
        if (!error)
          console.log('in event handler');            
      return  contractAddr.doSomething(account0, account1, {from: account0, gas: 4700000 });

The event handler is called twice. Is this an error on my part, or do I need to change something in this setup.

enter image description here


  • Is this .then part a success callback?
    – niksmac
    Nov 28, 2016 at 2:18
  • Yes. When I put an extra log in the then handler I can see that that part is executed once but the event twice.
    – BennyM
    Nov 28, 2016 at 5:40
  • I think contract.watch is global, you don't have to use it with callback.
    – niksmac
    Nov 28, 2016 at 6:03

2 Answers 2


Problem was in my code, obviously. Be careful when you create your event handlers. Listening to events directly after the contract was created and not chaining along solved the issue.

  • What do you mean not chaining along? Apr 25, 2017 at 6:20

I've coded up a utility function to filter events by name, arguments etc. Answered in a different question:


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.