I have a smart contract that broadcasts events to web3 clients, upon each event being broadcast, the listening client makes a tx call to my contract.

I would like to set up an 'always on' event listener - so some sort of web service and all it does is listen for events being broadcast from my smart contract and make tx calls. This way the browser would not have to be open to fire off tx to my contract when it 'hears' an event.

In my mind, obviously this webservice would need to have its own local node running, and have a coinbase with enough funds in it to run the tx.

How could I accomplish this scenario?

Basically, I need a web3 file to always be listening - with no one visiting the actual page in browser that has the js listeners.

Is this achievable? Would something like nodejs be able to do this?

Please help it is crucial to my smart contract application.

1 Answer 1


You could certainly make a daemon that listens for the event and calls the contract. As you describe it it doesn't even need to be a web service; For example, just write the code that you'd normally have run in the browser to listen for the event then fire the contract, and run it from the command line with node. You may want to run this with upstart or god that will start it up again if it falls over for some reason.

However, is there a reason why you can't just make the contract that's currently calling the original event call the second contract directly?

  • So nodejs can potentially run a node and listen for these events?
    – Jay Bee
    Mar 20, 2016 at 10:32
  • 1
    Node.js wouldn't be running an Ethereum node, it would be connecting to an Ethereum node. You'd have some code running in a node.js process that listened for messages from your Ethereum node, in the same way that you currently have code running in a browser JavaScript process that listens for messages from your Ethereum node. The obvious way to do this would be to have an Ethereum node and your node.js daemon both running on the same box, so the node.js daemon would connect to the Ethereum node on localhost. Mar 20, 2016 at 11:59

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.