New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Waku 🛠 Building with Waku

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join us for a Waku workshop! From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com

Transcript

[Music] today we'll be talking about uncompromising web three communication at scale with waku so introducing waku it's a family of robust censorship resistant communication protocols designed to enable privacy Focus messaging the six values of waku of waku are listed over here it's private it's censorship resistant completely modular adaptive securely scal and rate limited so talking about the history it all started with the ethereum white paper in 2013 when the etherium triology was introduced where ethereum was said to be the consensus layer swarm for the storage layer and Whisper for the generalized messaging but over the years uh there was not much of dedicated teams building on top of whisper and then in 2020 wh whisper was replaced by waku V1 in the status app so this was a benchmark here and today waku has has evolved into a standard of web3 communication when I say standard of web3 communication it's because of the ecosystem that we've built around of we have status app using waku rail gun which is a privacy layer built on top of ethereum using waku the graph is using waku for decentralizing their indexes and also xmt is using waku to build a specific use case which is chat so the key features of vaku are it's adaptive it can C resource restricted environments like brows ERS mobile phones to Resource intensive environments like clusters VPS home servers and stuff so it's highly adaptive and it's rate limited by Nature we have rate limiting nullifier which is a truly decentralized and Anonymous rate limiting technology using ZK proofs it's also open and permissionless so waku works on a Content topic based architecture and uh it's anyone can pretty much push messages into a Content topic and subscribe to a Content topic to retrieve the messages to get started with waku you have two ways of doing it the first one is to operate a waku node or to build on top of vaku for operating a vaku node you can do it with enaku or Docker or Docker compost command or even dap node which is just a few clicks for initializing your own vaku node if you're looking to build on top of vaku we have the following implementations uh which is JS vaku n vaku goang R bindings and C bindings you can find all of these codes in sdks open sourced on our GitHub so the resources the four main resources that I want to share here are the developer documentation which is available at docs. wu. and uh we also have a list of example apps that use waku you can check it out at examples. wu. org and you can also find the GitHub reposter in the organization and yeah the GitHub has all the open source code and we also have an RFC list uh which pretty much has the specifications for each and every protocol in the vaku ecosystem so I would definitely encourage you to check it out if you are digging deep into waku so for E Global Istanbul we have bounties worth $10,000 up for grabs so the first prize or the grand prize winner will be getting a $4,000 Bounty for the best implementation of vaku and we also have uh four different track prices with 1,500 bucks each the first track will be best network State Goods with waku the second being most creative use of waku third being privacy focused projects built on top of vaku and the fourth one will be best game or Marketplace built on top of vaku one thing that I wanted to highlight is that we don't really encourage uh General chatting apps or traditional chatting apps we are looking for more novel use cases through these hackathons so try to be as Innovative as you can and yeah we expecting the projects to be in those levels so finally some use case with waku you can build gaming apps marketplaces decentralized State channels or anything that can be done with human to human or human to machine communication you can also check out our curated list of ideas by the community at ideas.

wu. which has around 550 ideas you can also feel free to contribute to new ideas in the community so we also have a Discord chn uh server for us feel free to drop in and uh ask your questions and our developers are ready to help you out for the hackathon so I'll have my friend Danish to do a quick demonstration of the waku JS vaku SDK so we'll be building an app in the next 10 minutes awesome hello hello I'm Danish I'm a JS waku maintainer uh so for this quick Workshop we'll build and Guru mentioned we're not looking for chat based example so we're going to build a super simple app that gets you to vote on a specific question so you'll have four four options and there's going to be a question and generally you'd go around doing that by using some sort of a backend right but for this case we're going to use waku as the networking layer for it and we're going to propagate the answers of the users through waku and everybody's going to be able to see that so I'm going to assume is every does everybody here know about nextjs like starting a nextjs project right okay so so we'll skip that part we'll go into a project that has um nextjs set up and you can use whatever front end you want right um the second thing what we're going to do is we're going to have the the basic front end lay out that is that is not as important for the workshop right front end can be whatever we're we're going to focus on providing or integrating waku as a networking layer to communicate the votes so I have the project called W quiz right and it's in nextjs so opening this and zooming in this is the basic ttjs structure right we have these config files post CSS for some some styling stuff and what we want to look at is the app right um here we have the layout. ESX which is by default which by default comes with nextjs so we're not much concerned about this what we're going to look at is page. TSX right and here this is the logo we're not going to care much about the front end stuff what is going to be interesting here is four things we're going to keep it very simple what do we want we want to have a node we want to be able to connect to the network we want to send messages into the network and receive messages into the network now what is this message right let's start with defining the structure of the message we say we have a question with four options as its answers so we want to send or propagate knowledge about the um the question the question is of let's say structure it has an ID which can be unique the question itself which is of string the answers the possible answers and the correct answer so defining the type we're going to define a very simple interface it's going to have ID a question and a answer which is the array of strings let's skip the protuff definition for now this is useful when we're sending the message into the network going back to what we decided we need primarily four things we want to start start a node we want to connect into the network we want to get messages from the network right and we know what a message is at this point a message is simply an object which has an ID a question and an answers key create an creating a node right um this is let's use this for reference let's comment this for now and let's start from scratch and let's also open the docs on the side because that's how um I wrote the code and how we should expect to um write or get started with waku so going to docs nodes and sdks here you'll see all the um implementation docks going to waku SDK let's go to sending and receiving messages using light light push and filter so and filter light push is a light protocol that is used to push messages into the network and filter is used to subscribe messages from the network so that's all that we care about right now now creating a light node creating a light node is literally just two lines of code so we'll go here go back to wu. TS which is a file for us to keep all our utility functions and um let's call this create node and it does not take any arguments and that's that's what it does right um oh missing up yeah perfect it creates create light node and we're passing it a parameter called default bootstrap and what that does is it uses a predefined set of nodes that we're going to use to connect to otherwise if you do not want to connect to pre-existing set of nodes that waku has waku being a permissionless network you do get to have a you do get to run your own node and participate in the network and you'll get a multi address that you can use to dial so you don't you do not have to use a pre-existing node for Simplicity we're going to use the default Network and we're going to start the node one key Point here is going to be we are attempting connections to the network now we have to wait to ensure that we can use the protocol now so one simple helper function here is what we call as wait for remote peer and we're going to pass it um the node this function is pretty much all it takes to create a node and at this point if this function returns just returns cleanly this means you are connected to the network right and now what we want to do we want to be able to subscribe to the messages from the network um to do that let's let's see how we do that we've waited for remote pure and everything happens it's it's a pubs of architecture so everything needs to be over a Content topic for this we are we've used um we've said this content topic and it can literally be anything it can be e Global isan buul and it doesn't matter right or we just need to ensure that the content topic we choose is unique to our own application the next thing we want to do is of course we're going to be sending messages into the Network and receiving messages from the network and we used protuff right uh to keep it yeah we're going to okay question uh sure yes why use because we are interacting with multiple implementations so we need a way to serialize the message yes you can yes you can so you can encode it all it needs to be yeah yeah so it needs to be serialized and deserialized in a particular standard which is why we we stick to protuff but you can send it however you would want so to send and receive messages into the network and from the network we of course have to set up encoders and decoders to know how we want to uh serialize and deserialize the messages and it's as simple as creating encoder and creating decoder and passing it the content topic and all of these helper functions come from one package which is at waku SDK everything you need comes from this now to subscribe incoming messages now that we've set up our encoders and decoders um and we already defined the message structure actually going back to the interface this is exactly the structure that we also want to use for protuff in case we use protuff right and it's as simple as just um creating a new type and adding uh all the fields to it now assuming we also have the message structure sorted we're going to go we're going to come to sending messages in a second and focus on receiving messages from the network first right the function or the protocol we are interested in interested in is the filter protocol and uh let's just create a subscription object using this let's call this um subscribe to incoming vs as we did and um this takes in a few things but we'll focus on um writing the code to see what we want okay so we'll need a node for sure right and the node is of type A light node and the types as well come from the same package the next thing we want to do is well we have the subscription object but when the messages come to us we we want a way to decode the messages correctly right so we pass it the decoder and it's going to help us process the messages so we pass it this and the call back here is what you want to do with the message right so we're going to define a little call back here let's call it call back equals to and and um this is going to have the decoded message so let's call this the poll message and it's of the type decoded message and let's say let's just do well found decoded the right cool and the next thing you want to do is like of course pass it the call back and that is it that is it right this other thing we can do here is is to um get a call back from the user right because this the call back we've defined inside is just to decode the message so um yeah to decode this we're going to have to use the Proto definition and decode using that so the decoded message this will be um not the format we expect to get so for that let's see what we want let we'll want to see the poll message.

payload if it exists right if it does not exist well we don't want to deal with it um if it does exist we'll create the poll message object which is going to be well Poole message which is our prot above definition and then decode using that and uh yeah so now this is going to be our um DC realized message the serialization Der serialization can seem a little bit more adding more friction but in reality once you set it up for the first time it's pretty pretty seamless um once we have this then we're going to go to sending the vote right we have been we've set up how we can retrieve votes that are that are coming in live now we want to um send messages into the network or send our option into the network so so let's set that up and this takes in what let's see we're going to use light push so we got to create a Proto message and in this case the chat message is not right it's called P pole message and the the things that it wants is an ID a question and the answers right so we got to pass it um in arguments because we're going to use some front-end magic to basically just automatically send it to this function so let's pass it a variable which is well our vote and this is of the type I pole message and we're going to create this our vote and now next thing we want to do is we want to serialize this that that is done and well we just send it and we want the node that we send it with and we're going to use light push this time so light push is to push the messages into the network and filter is to retrieve the message from the network the node here is going to be of the type light node and well that is it the next thing is now that we have our utility functions right let's not focus on retrieving existing votes for now um um but this is another protocol which is the store protocol right and we this comes in handy when let's say you're offline but you still want to know without being online what are the messages that were sent while you were away so the store protocol stores your messages for an arbitrary number of days I think it's 30 days from now and after 30 days it just wipes the uh the data away okay now that we we have a way to send a vote subscribe to incoming votes and creating a node that is literally all we need going into our root of the app right which is Page this is our logo and some some loader stuff now within use effect well we can just remove this um we're going to we're going to create a state right which is going to hold our node because we want to pass this node around throughout the application and you can use some more Central uh State Management things but for this use case we're we're just going to stick with UST State um the next thing we want to do is we want to call this asynchronous function so we're going to do some janky stuff and um within use effect we're going to um create the node and set the node and then call this function um what is not assignable okay so we're going to we actually had to return the node we did not return the node here right so we returned a node here and this error goes away okay now we expect to have aaku node initialized as soon as the app mounts the next thing is the poll itself right um and to simplify all of this HTML we have a question we have four options right the questions are being mapped on the answers are being mapped on to render and that is all we care about and then there's an onclick um that handles the vote being sent so what is happening except sending the vote is you're you're listening to the messages you want to listen to the messages that are incoming and you want to let's say increase a counter on your options now for that we need to subscribe to our events for which we already have a utility function and the second thing we need is a way to send the message into the network so for that let's write our handle vote send and and we have this function called send vote right it takes in the node itself and the vote message there are multiple ways you can architect this you could create a class and then you would not have to pass the node every time there are multiple ways you can go about this for but for Simplicity we're going to stick with this so what you do is you get the index you find the vote the vote object and all you do is you just send it uh you just call this function now what it does in the background is it creates the Proto message for this it serializes it and then it passes it as the payload now one um little Nuance here is that over light push the maximum payload size is 1 MB and not the payload size it's actually U the entire encoded uh the entire serialized message cannot be over an MB um but most things should not Ross NMB it's a very generous limit in my personal opinion cool now that we know how we handle sending votes the next thing is we're also listening to how you receive votes and we want a counter to increase so we have this little function that takes in the poll message that that is received and finds the index for that option that is received and just increments the counter right not as readable but it it is pretty straightforward all it does is passes through the uh goes through the loops through the object and finds the option and increases the counter now on use effect well we handled uh sending vs the next thing we want to do is subscribing to events right and we have a function for that as well subscribe to incoming votes that that uses filter and it takes in a call back right now that call back is actually our process received votes that increases the counter so what that here we're going to call um our subscription uh function and that is pretty much it so just to recap and we're going to do a little small um demo of what we've buil built here I know we've not focused on front end because that was not as important and I think everybody here who's trying to play around with uh stuff would uh would be able to figure that out but what we care about here as well we were successfully able to interact with a network use it for a use case to propagate messages between peers and in a decentralized manner so the waku network is permissionless as Guru mentioned in the talk previously you can operate a node right now you can participate in the network yourself there is no incentivization but it is still permissionless and censorship resistant so without using any centralized uh service we were able to make a peer-to-peer application that scales and to see um how it looks like I if anybody of you have uh want to interact open your phones or your laptops or any machines and the URL is wyen pool. worell doapp and what we've made on this application is deployed here and the code is on the GitHub as well that we can link and what you're going to what you're going to see as you open your uh uh on your website is going to be connection a loader that says connecting to the network uh the URL of course sorry is that visible woolwell doapp and as you vote somebody voted and we're going to see the voting counter increase and as you one thing to note here is okay so somebody thinks the taxis are the favorite part well I I would Guru would disagree Guru got scammed yesterday you're the one who voted it well so the interesting part here is that well there is no centralized server involved we're connected to a decentralized network which is peer-to-peer in nature and well that concludes our presentation the use cases are endless in terms of waku being a networking layer it is very modular chat applications are the most direct and the naive use case and we have seen some of uh the community projects and partners do that we also have as Guru mentioned uh project like rail gun that use it for their private uh blockchain then we have silence Labs that use it for multiparty computation silence Labs yes um not not silent protocol silence Laboratories they do multiparty computation so we're looking for these novel use cases and um as Guru already expanded two people seem to think think taxis are the favorite part about Istanbul well that is all from my side and uh yeah okay questions please yes yes so that is a very important point we waku does not um link any identity to your session to your message right so every time you refresh well what let's say I vote here right and now the input boxes are disabled well that's a front end thing right you can just inspect the element and you can play around with that so to sort of enforce some sort of identity we expect the application layer to integrate their own Solutions and that is how the sort of modularity into the pro into the protocol comes in waku is strictly used for the communications bit the message propagation bit everything else is uh can be integrated with it so you can attach a wallet here and we have some examples on our GitHub examples. wu. org and some of them use um wallet connection as an identity so yeah you can be creative you can be novel about it and uh sort of uh play around with it yes amazing question so spam and dos protection is something uh waku and its research entity wak has been thinking about and solving for a very long time in tandem with PSC and Alvaro here is is here who actually implemented it for waku thanks to him so there's an algorithm called rln which is which stands for rate limiting nullifiers which uses ZK and uh he's probably the best person to answer this uh so there's a membership set and it's deployed on a on on some chain it's a polia for now we're testing it out on a test net you yeah and you register into the membership set then every time you send a message your uh you have your proof attached to your message right and it is cbed there's a there's a cap on the number of messages you can send into the network and anything that is not does not have a proof attached will be still be able to send but it it'll not be prioritized is that correct Alvaro any ass cont you open any other questions all right thank you so much we'll be around at the we have a booth uh on the left we'll be around to entertain any questions any sort of help you might want and of course Discord is also a great place to get very prompt assistance all right thank you so [Applause] much

Automatic transcript — names and jargon may be misspelled.