1

I would like to create a sever that continuously watch the events of multiple smart contract at once. Sending me an alert via email when an event is detected.

I understand that there is a web3.js function that watch contracts. But how do I make it run perpetually on my server to do the task?

Furthermore, when there is an additional contract i would like to watch, is it possible to dynamically watch the new contract.

Thanks!

0

You can use WebSocket protocol to connect to Ethereum node and subscribe for the contract events. WebSocket pushes events to your server as fast as they arrive to the node over Ethereum network gossip.

You can find more details in this blog post https://hanezu.github.io/posts/Enable-WebSocket-support-of-Ganache-CLI-and-Subscribe-to-Events.html

You can subscribe to multiple contracts (addresses).

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.