Back to All Episodes
Season 2Episode 70

Streamr Network

June 17, 2023
32m
1 Guest

Listen Now

About This Episode

In this episode of DevNTell, Narb interviews Nico Burkart, Developer Relations Engineer for the Streamr Network. Nico provides an in-depth look at Streamr, a decentralized peer-to-peer (P2P) real-time data network. He explains that Streamr operates on a topic-based publish-subscribe (pub/sub) pattern, allowing users to stream data to any number of Ethereum accounts in real-time. Nico highlights the network's key properties, including its scalability, permissionless nature, and end-to-end encryption. He demonstrates how access control is managed via smart contracts on the Polygon blockchain. The presentation includes a code walkthrough showcasing the Streamr JavaScript client, demonstrating how easily developers can publish and subscribe to data streams. Nico also explores various use cases for the network, ranging from decentralized chat applications to IoT connectivity and real-time gaming.

Key Takeaways

1

Streamr is a decentralized, P2P network designed for real-time data streams using a pub/sub architecture.

2

The network is highly scalable, demonstrated to handle up to 80,000 nodes with minimal propagation delay.

3

Security is prioritized through end-to-end encryption and on-chain access control registries on the Polygon network.

4

Developers can interface with the network using Light nodes (integrated directly into apps) or Broker nodes (standalone nodes supporting protocols like MQTT).

5

Potential use cases include wallet-to-wallet communication, decentralized chat, IoT sensor data, and low-latency multiplayer gaming.

Featured Guest

NB

Nico Burkart

DevRel @ Streamr

Streamr

Episode Transcript

Narb

All right, we're live. GM, GA, GE everybody. Welcome to what's going to be another great DevNTell. So, if you didn't know, DevNTell is a 30-minute window for builders to showcase something they are passionate about or working on in Web3. This can be an awesome project you've been working on, demonstrating new testing best practices, automation goodies, how to structure a project, etc. Basically, if you've got a passion for something, this is your opportunity to share it with the community here. And today, I am ecstatic to have Nico from the Streamr Network. Welcome, Nico. Thank you for coming back on after our scheduling issues a few months back. It's a pleasure to have you on, man.

Nico Burkart

Yes, thanks for having me, guys. Yeah, conferences.

Narb

Yeah, right. Conferences. I guess, from our standpoint and folks who didn't catch you the last time you were on DevNTell, do you want to give kind of a brief background about yourself, who you are, how you got into Web3, and how you got into Developer DAO?

Nico Burkart

Yeah, sure. Well, I'm Nico. I am the developer relations engineer for Streamr Network. And how I got into Web3 is a cool question. I actually got into Web3 with Developer DAO simultaneously. So, I joined Developer DAO, got the NFT, and then I applied for a sponsorship to get into EthAmsterdam, which was Devconnect, actually. And they sponsored me. I was very lucky to go there, and we won the ETHGlobal Hackathon. I think for the Graph, yes, for the Graph we won first place, and that kind of got me into Web3 and got me some opportunities, and now I'm here. So, yeah, big thank you to Developer DAO, and I'm very happy to collaborate with you guys, representing Streamr.

Narb

Excellent, excellent background story there. And I'm sure a lot of folks in the DAO share a similar one as well. Yeah, the DAO doing God's work, so to speak. So, what do you have in store for us from the Streamr Network side?

Nico Burkart

Yes. Okay, let me share my screen real quick. Let me share my entire screen, I know it's a bit scary but... There we go, and then let's start the slideshow. So, I won't be able to see the chat or anything. So, if there is anything coming up, just let me know, or we can just answer questions afterwards. I think that's the easiest. So, yeah, I think I'll just jump in. Shall I?

Narb

Yes, sure. Yeah, let's do it.

Nico Burkart

Okay, okay, let's go. All right, so Streamr, basically I'm just going to give you guys an overview of what it is, what we do and what we offer, what you can do with it, and then jump into a little bit of code, show you how you can build with Streamr. And then if you have any questions, happy to answer them afterwards. And, yeah, let's go. So, Streamr is a decentralized real-time data network. So, what is it? Basically, we have a P2P network which is decentralized, so peer-to-peer network. We are a topic-based publish-subscribe system. If you don't know what publish-subscribe is, no worries, I'm going to explain it in a minute. And then we basically stream data to any Ethereum accounts in real-time. So, if you have data that you want to send from A to B in a decentralized and secure manner, you can do that with Streamr. So, for example, if you have like chat messages you want to send decentralized, you can. If you have notifications you want to send in real-time and that decentralized, you can do that with Streamr. So, all of these like, whatever data you can think of that you want to send in real-time, you can do that via the Streamr network. At the moment, we do, for example, JSON-based data, so anything JSON-based data you can send—IoT devices, whatever you can think of. More about that later.

Nico Burkart

So first of all, how do we do that? So, in order to explain that, I think I'm just going to explain what streams and topics are in this pub-sub pattern. So, if you have heard of pub-sub, you can think of the topics as the streams, so we can replace that name there. And if you haven't heard of it, I'll just explain it real quick. So, what we have here, this orange thing here, I try to kind of visualize that as a stream. And you get the data from A to B with that, right? So, let's say we have a weather app where you have like different stakeholders in that stream. So, one is like the weather station, another weather station, and you have the actual app that maybe displays the weather data, right? So, that could be a dashboard, that could be... yeah, let's just say it's a dashboard that displays weather data, right? So, what we have here is we have two weather stations—let's say we have more—that publish data onto this stream, in order to display them somewhere in an application. And this application is the subscriber, and it's reading from that stream, okay? So, let's say, maybe just think of a stream as like a table that the weather stations write to, let's say every second. So, they write like a JSON object onto this table—write, write, write every second—and the application, the subscriber, subscribes and reads from that table every second, right? So, this is kind of what this stream is. I hope I explained that well enough to understand and to have the foundation to understand the rest. So, again, it's like a table, as you can see here, this is like an example stream where, in this case, we have publishers that publish the Ethereum 2.0 burn stats every second, right? So, you've got this one, 49, 48, 47, or every minute I think in this case. So, think of it as a table that you have publishers that write to it, and subscribers that read from it, okay?

Nico Burkart

So, how does this work with a peer-to-peer network? And I don't want to bore you with all of this like theory, but it's just so you understand why this is cool and what it does and what Streamr does in general, because not a lot of people even get what a peer-to-peer network is, what like a pub-sub messaging system and all of that is. So, I just want to kind of get you guys from zero, and then we can go into the code. So, here we can see the stream topic overlay network of like one stream of that, let's say that table you just saw, right? See, I think what would be cooler is if we go into here. So, here you can see our whole network, right? All of our nodes. If I refresh this, does it show how many nodes we have? Yes. So, we have around 7,821 nodes right now, all participating in the network. However, if you have a specific stream, let's say you have this weather data stream, and you only have 30 nodes distributed all over the world, only those 30 nodes will participate in your stream and your transporting data from A to B, right? So, let's... I have an example stream ready, yeah, this one. So, if we go into here, and look for the stream. Here we can see this one specific stream, right? You had like all these 7,200 nodes, and now we zoomed in into one of the streams of Streamr Network. This is shown in metrics, but let's just assume this is this weather example we said earlier. And all of these nodes publish data into this mesh network, right? So, you've got like Vancouver, for example, publishing data to its neighbor nodes, those are its neighbor nodes, and then it sends it to Finland, for example, and Finland sends it then to its neighbor nodes, so this is kind of, you know, data flowing from Vancouver—let's say this node publishes data, Vancouver publishes data, sends it to Finland, Finland distributes it to its neighbor nodes, and this is kind of how everyone gets the message, right, when a message gets sent. And then, for example, France could be like, 'Hey, I want to subscribe to this data, I want to read from it,' and then France can read from it, but also publish and kind of distribute it further through the network. And that way, everyone kind of gets this message within the network. And this is how our pub-sub messaging mesh network works, right? Cool. Let's continue. And when I did this presentation, I was at ETH Denver, so a few months ago, we only had 5,000 nodes. When I say only, that's still quite a lot. So, as you can see, our network is growing quite nicely at the moment. So, yeah, jump on the bus, or however you would say that in English, and work with us. So, does it scale? We did a test back in, I think 2019 or 2018 with the network, and checked if our way of doing this decentralized network actually scales, and you know, if we have like 80,000 nodes, I just said we have 7,000, what happens if we have 80,000 nodes? Will the network kind of work still? And yes, indeed it would, as you can see here with 20,000 nodes we're like around 200 millisecond delay from like data getting from A to B. And here we get with 80,000 nodes we get around 400 milliseconds delay, and it kind of, you know, does this like curve.

Nico Burkart

So, yeah, does it scale? Yes, I would say so. So, some properties: we're fast, real-time, and we're scalable. We're permissionless, censorship-resistant, we're tamper-proof, more about that in a second, end-to-end encrypted, and we're completely free to use. So, you know, if you want to use Streamr, you can do that right now. All you have to do is create a stream, which does cost a little bit of a transaction fee on Matic but, you know, it's like less than a cent. And then you're just free to publish data through our network for free, completely. Okay, so we do, we are not a blockchain, just saying, we're a peer-to-peer network, but we do use the blockchain, as I just mentioned, we use Polygon at the moment for access control and security. So, if we want to see, 'Okay, who is allowed to publish data onto this stream?' you can check on the smart contract, the addresses that are allowed to stream data and who are allowed to read from that data. So, it's like a permission system with that smart contract. So, let's say you have a chat app, and in that chat room you only want to allow specific addresses to read the messages, right, in a chat room? You don't want a public stream where anyone could just read your chat room, right? So, in that case, you can then kind of say, 'Okay, this is the permission of address A, B, and C and D, and they can all read and write within that chat room, but address X couldn't, like just a random address, because it doesn't have the permission.' So, obviously, there is this access control policy in place, so we have the ability to secure your messages, and they're all encrypted, so there's no way of someone just, you know, tampering with the data, like let's say a network operator, or maliciously doing anything with your data or reading the data, there's no way of doing that.

Nico Burkart

Cool. So, that I explained. So, yeah, if you want to build with us, there are two strategies of interfacing with the Streamr Network, and that is: one, a light node, which is essentially your browser. So, that would be a React JS app, for example, Next.js app, whatever you want to build. It's a Node package that you can install into your web application, and then you can kind of become part of the network and interface with the network, send messages from A to B. And I'll explain that in a minute how that works. Or, if you have like more of an IoT use case, you can also use a broker node, use MQTT, Websockets, to integrate with the network. And you know, if you want to send your fridge data, or your Raspberry Pi data, you can do that with a broker node, and MQTT, and everything that's possible. Yeah, so again, the Streamr client SDK right here, I'll go into that in a minute. And then the broker node, this is all explained in the documentation, and I explain it in an example now. So, again, we have documentation, docs.streamr.network. I think Narb will send the link in the YouTube description anyway, so if you want to have a look there, there are some quick start guides that you can follow to get started with Streamr. And, you know, I explained quite quickly right now but, if you want, you can have like another read of how everything works and everything that will be explained in the Streamr docs. And obviously, you can always ask me as well.

Nico Burkart

So, yeah, let's go into a little bit of code. I'm sorry, I hope I didn't bore you guys with all of that theory. Let's see. Yeah, there we go. Okay, so here, I created a stream already, and I have this stream ID right here, right? So, all of our streams are in the stream registry. The stream registry is on Polygon and keeps track again of all the permissions, right? So, this is our unique stream ID, in this case, it's eth-denver because the last time I did this, or the first time I did this, was in EthDenver. And all you do now is we have the Streamr client—obviously, npm install streamr-client and all of that, I'm assuming you guys know what npm is—and you have this Streamr client object that you feed a private key. You can also do this with a wallet connect, in this case, I just hardcoded it with the private key. And then what you can do here is you can publish data. So, let's say we publish the latest Bitcoin price every second in this case. So, we set an interval, I call on the Streamr client, I call 'publish', so I want to just publish data now, and then whatever I want to publish I can put in here. So, this is my object here, 'btcPrice' and 'streamId', this is what I'm publishing, btcPrice, just you know, Math.random, whatever, and I do this every second, right? Let's just run this very quickly, hope it works. Yeah. So, as you can see right now, what I'm doing is I publish data every second. And this could be anything, right? It could be Bitcoin price, it could be, again, your fridge temperature, it could be weather data, like whatever you want to publish, you can do this with like these few lines of code. And obviously, this, so you just kind of have to set, 'Okay, this is my Streamr client, this is my Ethereum address that I authenticate with, this is the stream ID I want to send data to,' and then you can just start publishing. So, fairly straightforward.

Nico Burkart

And now what I want to do is I want to have this React example here where I actually subscribe to the data. So, this is a browser application that I built, very simple one. Let's just start it real quick, I'll show you, I'll go into the code in a minute. There we go. So, the current price is zero because we are not subscribed to the stream yet, but if we click this button we will get the published data that we are publishing to the stream. So, what we are doing here, again with the private key, you can also just configure this as a MetaMask wallet provider, and then you can put that in the authentication. That's explained in the documentation, I just kind of want to show how this works and how simple it actually is. So, you have the private key, you've got the Streamr client configured, you've got the same stream ID that you just saw in the server, let's say. And then we have this method here, streamr.subscribe, where you subscribe to the specific stream ID, and then you can... it's just like a callback with the message, and you can get the Bitcoin price essentially, and then I just give it to this widget that displays it. So, if we go here, and we start subscribe... subscribing... I can close this. Yes, so this, I just got some historic messages, that's why it went this fast. And now I'm getting like the Bitcoin price that I'm publishing every second right now into my application. So, this is currently what's happening. So, as you can see, it works. And, yeah, it's really cool. Like, you can do, again, you can do whatever you want, any real-time data you can think of works here.

Nico Burkart

Yeah, okay. Cool. So, another example what we built, for example, is this chat app. If you want to check it out, you can do this here. Let me make this a little bigger. There you go. So, we have the chat app, you can find it... find the source code here, and the actual chat app you can find here, but I think there is another link as well in the source code, so like the actual app. Hang on, I think it's just thechat.app. Yes, there you go. So, if you want, this is what we built, a decentralized chat app. Just showing you guys this as like an example. And what happens here is you can, like WhatsApp, but like with your Ethereum address. And everyone and their mom has a chat app right now, I know, I know, I know, but this one is cool because this is completely decentralized, right? So, if we go back to this...

Nico Burkart

...to this thing, so this could be your chat room, right? You are... your chat room is basically one stream, and it's all over the world, like whomever you're chatting with, and you're all like kind of part of your own network. So, this could be one of your friends' Ethereum address right here, and then you could be in the United States, be another address, and you kind of all be in that one network, sending messages to each other. There's no centralized server in the middle, there's no AWS or anything working right there, it's just your phones communicating with each other. So, that's really cool, and I want to point that out because that's the difference that we are making to all of the other apps out there. So, let's go to here. So, again, this is one use case. Another one could be like a group chat on Lens Protocol, for example, or decentralized real-time wallet-to-wallet communications, instant messaging, event-driven notifications, IoT connectivity—right, the fridge example I gave earlier—or climate data streaming, even multiplayer gaming, like imagine you could build like a chess game, or something else. Build a data DAO, like where you incentivize your users with tokens in exchange for publishing data.

Nico Burkart

We also just launched an Ambassador Program. If you guys are like interested, if all of this sounded interesting to you and you want to do something with us, you can scan this QR code and sign up with your email, and we're going to send a message to that email, probably next week, and then kind of connect with you guys and see, see how we can work together in that Ambassador Program. So, if you're interested, just sign up there to get some more information about that Ambassador Program. Cool. If you have any questions, you can reach out to me via Telegram, Twitter works too, my Twitter is the same handle as this one, so @nicoburkart. And then of course, also Discord works too on the Streamr Network's Discord. But yeah, if you don't want to join the Streamr Discord and just want to reach out to me, you can do that here. So, easiest possible. And then over to you, Narb, if there are any questions.

Narb

Yeah, we have a couple actually. And, yeah, this was actually very, very insightful. I have a couple of questions of my own too, we'll get into. But first, the crowd. James asks, 'Will it be possible to stream video data using the Streamr network?'

Nico Burkart

Ah, that's a good question. So, okay, so what we're doing right now is what we have right now is JSON-based data, right? So, yes, it is possible, but it is a bit tricky because you have to base64 encode the data, which is not ideal, right? But what you could do in the future, what we are building on right now with Streamr 1.0, is we want to enable binary data, and then it should be completely possible to send video data, yes. We're also working on file data right now but, again, same problem, right, we have to base64 encode it, so it's not ideal. But yes, it is possible.

Narb

Awesome. Looking forward to that and seeing people make their decentralized Zoom apps. Harry asks, 'Is there any ordering guarantee for the messages?' And I guess a tangent on that as well is, can you say, 'I don't want to subscribe from the beginning of time of all the messages, I want like every message starting from yesterday?'

Nico Burkart

Yes, that's completely possible. So, you can... you can set... there's an option, it's in the documentation where it says 'receive historic messages', for example, where you can only say, 'Okay, from yesterday I want the messages.' In order to do that, you have to enable a storage node, that's also explained in the documentation, so yes, it's possible. And then for the ordering guarantee of the messages, there's no guarantee of the... like what order you will get receive the messages, it's just not the nature of the pub-sub network that we have. But if you trust the timestamps that are inside your messages, then it would work. You could kind of say, 'Okay, I send this message with this timestamp,' so it's, you know, it came in before, and then you maybe have like a buffer of one second or something where you can order the messages inside your application, so yes, that would work.

Narb

Cool. Good to know. And again, if you have any other questions, please type them in the chat and I will ask on your behalf. But in the meantime, I have some questions of my own. So, for subscribing, is... for the person that's hosting, hosting the node and providing the data, do they gatekeep who can subscribe and who cannot?

Nico Burkart

The node itself can't. So, you always have... you always have the creator of the stream, right? So, let say I am the operator of a weather app, and I created a stream that people can stream to. Or let's say I'm... better example, I'm the admin of a group chat. So, I'm the creator of this group, so I'm the creator of the stream, right? So, I can set the permissions on the Ethereum smart contract because I'm the owner there. So, I can say, 'Okay, you can... I'm going to add you, Narb, as an address, and then maybe another friend, maybe Kamp, and so on and so forth.' Right, I can add the addresses. So, no, like the node itself cannot decide it, because it's just another address in the network. But I as the admin, I can because I created the stream, and I can also give you permission to be another admin, for example.

Narb

I see. So, the use case I'm kind of thinking about is like if enterprises want to adopt this as an alternative to AWS SNS/SQS, can they basically have like a dedicated peer-to-peer network amongst themselves and not have the outside world be able to read that stream?

Nico Burkart

Yes, yes, they can. Because, so every, every node that participates in this network, in your stream-specific network... let me just pull this up again... this one. So, let's say this is our group chat with, you know, 26 people in the group chat. And if I send a message, or you send a message from Vancouver over to Portugal down there, where I am right now, this would go kind of, Vancouver, Finland... and at some point, it would end up in Lisbon right here. And every single node checks if... so if you send data over to Finland here, for example, the Finland node will check, 'Hey, is this node even part of this network? Is it even allowed to publish data?' And it looks up on the blockchain, on the smart contract, if you are indeed allowed to send data to the stream, right? And another thing, so if, let's say, the Finland node wants to read the data, it needs to request a group key to actually be able to decrypt the data, right? Because all of the data is encrypted, so as you said, like an organization could just use our network without a problem because it's all encrypted. So, the Finland node then sends a request to Vancouver and says, 'Hey, I need the key to actually be able to read the messages,' and then Vancouver will first check, 'Hey, has this node the permission to read the stream?' and if that is the case, sends the group key over to Finland, and Finland is then able to read the message.

Narb

Awesome. Yeah, I'm sure a lot of folks would be wanting to, at the very least, experiment with this to see if they can get away from the crutches that AWS has over the pub-sub world. But, yeah, unfortunately, we have come to time, Nico. We probably could have gone another 20-30 minutes on Q&A alone, but it was a pleasure having you on. Thank you so much for taking the time to come on here. And, yeah, really looking forward to seeing what people start building with Streamr Network. I know we had some really good submissions the last time Developer DAO had a hackathon with Streamr, so... And, folks, just before you tune off, want to present you with the QR code to claim your KUDOS for attending today's DevNTell session. So, what you're going to want to do is pull out your regular QR code scanner on your phone, scan this code, and you'll be taken to the MintKudos website where you'll be able to mint your special attendee KUDOS for coming on today. So, again, you'll want to grab your regular QR code scanner, scan this code, and you'll have one hour from now to be able to claim. And with that, just want to wish everybody a very happy Friday, happy weekend, and we'll see you back here next week. All right, guys. Cheers. Bye.

Listen On

Share This Episode

Share on X

Watch Episodes Live!

Subscribe to our event calendar and never miss a live episode.

View Event Calendar