Build your own websocket event stream for Ethereum using Amberdata.io! Example code uses Amberdata's Websockets
Check out the demo page!
git clone [email protected]:amberdata/amberdata-example-websockets.git
Go to amberdata.io and click "Get started"
Building with Amberdata.io is as simple as a few a few lines of code:
// Create WebSocket connection.
const socket = new WebSocket('wss://ws.web3api.io?x-api-key=YOUR_API_KEY_HERE');
// Connection opened
socket.addEventListener('open', function (event) {
console.log('Connection opened - ', event);
socket.send(`{"jsonrpc":"2.0","id":0,"method":"subscribe","params":["block"]}`);
socket.send(`{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["uncle"]}`);
socket.send(`{"jsonrpc":"2.0","id":2,"method":"subscribe","params":["transaction"]}`);
socket.send(`{"jsonrpc":"2.0","id":3,"method":"subscribe","params":["function"]}`);
});
// Listen for messages
socket.addEventListener('message', responseHandler);
See source here.
This project is licensed under the Apache Licence 2.0.