I have a Node.js app that receives events from an Ethereum Smart Contract. I also have a WebSocket server that maintains communication with the client-side app.

When my Node.js app receives a Smart Contract event I would like to send the data down to the client via the WebSocket connection.

const server = new WebSocket.Server({ server: app.listen(8080) });

server.on('connection', socket => {
  socket.on('message', message => {
    server.clients.forEach(client => {
  socket.send('Hello World!');

Web3Instance.events.Result((err, res) => {
  console.log(err, res); // incoming event - how do I get this data to the client?

How can I get the received event data down to the client via the WebSocket connection?

0 Answers