const socket = new WebSocket("wss://production-stream.mobula.io");socket.addEventListener("open", () => { socket.send(`{ "type": "stream", "authorization": "YOUR_API_KEY", "payload": { "chainIds": ["evm:1", "evm:56"], "events": ["trace", "log", "transaction", "block", "swap", "transfer", "pool"], }}`);});socket.addEventListener("message", (event) => { const data = JSON.parse(event.data); if (event.reorg) { // Handle reorg return; }});// No need to close the socket, it will close automatically.
You can use the Network tab in your browser to see the WSS requests.
After sending the unsubscribe payload, you will stop receiving events for the specified stream.Can’t find what you’re looking for? Reach out to us, response times < 1h.