0

I'm currently working with Ethereum and smart contracts. I see that a contract can define events and emit them. Each event defines no target, so I assume it will be broadcast. But I wonder how to listen to these events from a nodejs server or web client. Do I have to poll Ethereum nodes continuously for determining if my event is dispatched or not. Is there any way to dispatch event directly to a target (like web callback or web hooks)?

Thank you!

  • Here is an explanation how events are modeled on top of the EVM log entries https://ethereum.stackexchange.com/questions/11228/what-is-an-event. – Ismael Jun 25 '19 at 14:51
  • 1
    tks @Ismael, it turns out ETH supports a rpc pub/sub api for this kind of work. web3 just subscribe and received push notifications from the network. no need polling continuously. https://ethereum.stackexchange.com/questions/48927/web3-detect-listen-to-events-if-someone-send-ether-to-addresses https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB – Nam Nguyễn Jun 25 '19 at 17:08

1 Answers1

0

You can refer to this link to solve your doubts.

Listen to events using web.js

Mahesh Rajput
  • 1,211
  • 7
  • 17
  • Hi there. Can you include some details from the link in your answer? If the link becomes dead, or gets moved, then the answer becomes useless. – Richard Horrocks Jun 25 '19 at 14:22