Simplifying Substreams: A Quick Guide to Using WebSockets for Real-Time Data Transfer

Substreams By Jan 09, 2024 No Comments
TL;DR: Learn how to connect your application to Substreams using WebSockets and access real-time blockchain data with lightning speed.

In the dynamic world of dApp development, connecting your application to a Substream can often be a challenging task, especially for developers with limited Substreams experience.

In this blog post, we’ll explore how Samuel Papineau, a developer at Pinax, simplifies the process using WebSockets.

What’s the problem?

Working with Substreams poses a steep learning curve and can be challenging to set up, especially for those with limited experience. To address this, we’ve developed a solution called Substreams Sink WebSockets, which offers you seamless data transfer between Substreams and your application.

Why WebSockets?

WebSockets offer us real-time data transfer, low latency, and create an ideal environment for developers with varying Substreams expertise. Our WebSockets leverage the Bun WebSockets API, built with uWebSockets, boasting speeds that are 8.5 times faster than Fastify WebSockets and 10 times faster than—two commonly used WebSocket libraries.

How does it work?

In our WebSocket solution, Substreams acquires data from the blockchain using Firehose endpoints, the Substreams sinks grab this data through a webhook, and finally, the WebSocket listens to the data sent from the webhook, transmitting it to the client. This real-time data flow ensures seamless integration and quick response times.

How WebSockets work.

A quick demo

Let’s dive into a quick demonstration of our WebSocket API. Whether it’s pinging the server, subscribing to a connection, or checking the server time, it’s as straightforward as it gets. In a real-world scenario, your application would receive a continuous stream of data from the Substreams, keeping your content updated.

Future enhancements

We’re committed to continuously improving our WebSocket solution. Our plans include retrieving data based on the chain name, simplifying the connection process, and enabling access to past data, offering a more comprehensive and user-friendly experience.


Connecting your application to Substreams doesn’t have to be a daunting task. Thanks to Sam’s insights and the power of WebSockets, you can achieve real-time data transfer with minimal effort. So, if you’re a developer looking to enhance your application’s capabilities, give the WebSocket a try—it’s the simplest tool for connecting to Substreams. Happy coding! 😎


I am a seasoned technical writer with a passion for simplifying complex tech topics, especially tech around blockchain and web3. Beyond writing, I also love coding as a hobby, with Rust being a particular favorite. This dual passion enables me to bridge the gap between technical intricacies and accessible content.

No Comments

Leave a comment

Your email address will not be published. Required fields are marked *