Listening to contract events on the Node JS server

How can I listen to contract events on the node js server?

  1. We call the contract function on a react app;
  2. This function emits an event;
  3. I want to listen to it on nodejs;
  4. And from there create a raw document that would be stored in mongo.

Unfortunately, I cannot use Moralis on this occasion. I’m looking for a way to do it without it.

you can sync the events directly in mongo db in your moralis server:
https://docs.moralis.io/moralis-dapp/automatic-transaction-sync/smart-contract-events

Unfortunately, we cannot use a Moralis server. How would you go about it without it?

You can send rely on moralis server to send data down to your server due to an event. https://youtu.be/PEILxU53-Zs

Unfortunately, I cannot use Moralis on this occasion. I’m looking for a way to do it without it.

you can listen to events by using websocket for example

there is an example here:

1 Like