 I want to talk about our lessons that we learned by building a decentralized application on top of Light Client. Who of you here is fairly, like, who of you know what is a Light Client? Like, kind of, if you think you know what's like fairly well, what's a Light Client? Okay, it's like half of the person, so I will be a bit slow at the beginning just to make sure we're all on board on why we want to use a Light Client actually. By the way, I will use the words Light Client, Light Node. For me, it's the same because we're talking about a Node. So just two words about myself. I'm Thibault, I'm working at Parity, I'm a front-end dev and I work on Parity Feather, which I will talk about right now. I work also on Parity Siner, which I had to talk about before. Pretty interesting, you should check it out and right now I'm actually working a lot on Polkadot, JS and UI. So this talk is about three things. We want to understand first why we want to build or use Light Clients. Then I will show you how to hack on a library that we made that's called LightJS and then in the end I'll show you a bit more about Feather, this application that we built on top of a Light Client. Here you can see I use Light Node inside an electron app. Light Node, Light Client, same thing. So let's start why Light Clients are important. So first of all, you probably all know but running a full Node is not as simple as it could seem or as simple as we hope it would be when people built a Node in the first place, we thought okay everybody should be able to run a full Node on a laptop, right? Well it's not really possible anymore so what do what people do when you want to build a Light Client or sorry when you want to build a decentralized application you do not connect to a full Node, you connect actually to Infra or to a third-party service that provides you a full Node to access the blockchain and the thing is Infra is super awesome like you can build an application connect to the blockchain within a couple minutes that's really really nice like it helps a ton the community to grow but there are many problems in there yeah those are numbers that I mean actually kind of old numbers is probably much higher now how many DApps have been developed using Infra how many billions of requests Infra is actually serving the problem you can all see that we call these decentralized applications but we're all connecting to one server here like or one set of server that is owned by a company that is not decentralized that's actually not the right thing to do right so what is a Light Client? It's a Node that stores header but will remain trustless so it's a Node so it's something that does access the blockchain and can give you many information about the blockchain can help you do almost anything a full Node would help you do from a decentralized application perspective but it is not decentralized it is sorry decentralized and it is not centralized it is it is just and it does not so it's not as secure as a full Node I will not talk about this in this talk because it's just it gets too complex but it is trustless so you cannot get fake data or something you know it's decentralized and it actually verifies all the requests and all the information that that it gets so just a couple yeah numbers to show the differences between a full Node and a light Node or Light Client the sync time is a couple seconds if you're lucky if you're not so lucky maybe a couple minutes but we're not talking about hours or days right as long as you have internet I'm not talking about this Wi-Fi here because it could be could be minutes or days yeah I tried it I did sync a light Node in the Chinkansen for instance with my 4G right it took a couple minutes but it was it was doing doable the state size so how many gigabytes or whatever are you going to download on your mobile phone or on your PC with a light client it's going to be zero it does not source the state with a full Node of course that's its job it's going to have gigabytes and gigabytes of state and the database that you're going to have again on your on your desktop or on your mobile it's going to be tens of gigabytes people are talking about terabytes I won't go into this debate but anyway for full nodes and like client is we're talking about couple hundreds of megabytes so what is a light client or why do we want to use a light client so today you have on the right the nodes the full nodes that are connected to each other and they form the Ethereum network and you have your decentralized application that is there and sits there and when you want to connect when you connect to say in FURA you connect to one of these nodes or let's say a set of node that is owned by a company and you trusted this person so this person can actually turn bad and what they can do is they cannot change your transactions or something they cannot you know spend your money on your behalf or something that's okay but still they can track you they can exactly who you are with the IP they can see okay this person is using this address all the time like they can do many mean stuff or they can censor you right infrared they are nice we know them and they actually want to get decentralized more they had talks about it I'm just saying this is not the right way to onboard people we all know that okay we want to care about decentralization in the space that's why we want to bring people more people to the space so let's let's do it right and what we can do is so the the new dots here or light cleanse so they are connected to full nodes and what we want to do is actually embed a light client in our app this is what we did and this is what we want actually to let people do more so to let people embed a light client and use a light client in their decentralized application we bought a library that is called like just so it's super light it's for light client everything is light and here's what here's how a stack that you would have today for your normal app so basically you have your UI in JavaScript most probably using React Angular whatever then you embed web 3.js which you want to use to just send transactions and do stuff on the blockchain this web 3.js one of the first thing you do with web 3.js is setting a provider you have new provider and there you most probably use some URL from Infra with a token that you have and then Infra so this centralized service node that you have to trust in this case we'll talk to Ethereum and what we want to do so yeah these guys can eventually censor you or or track you and so what we want to do with this light.js is actually instead of web 3.js you use this light.js and this we'll talk to a light node on your own inside your app actually and you will talk directly to the Ethereum network so the difference here is that you remove right the centralized node and you put the light node actually inside the app right so this light.js library is a high-level reactive and easy to use library we'll talk about it just a bit we are well how do you install it just like any other library you probably saw today it's from the parity name face and slash light.js so let's have a look a bit at some code I hope you can see that all right so that's a really simple sample code so you can see that we import lights and we import balance off and block number and those balance off and block number have a dollar behind and it means they are these are observable and just like you would do with web 3.js today you would just do light set provider with your provider and then you can do with these observables block number you can subscribe for instance and this will give you a block number that you can log and so in this in this little program we'll just subscribe with the block number and just log the current block number and we do kind of the same with balance off so balance off you want to say which address you want to see the balance off and then I don't know if you if you were or if you know how to use reactive or or xjs but basically you can get what's the result of balance off and pipe it and do something with this with this result so what we're gonna do is this balance is gonna be formatted or you have a question so the question is will balance off well be actually a stream and updated and the answer is yes and this is the nice things without observables and you'll see that in a second so the balance off will be you know not formatted nicely so what we want to do is from way we want to format it basically and then what we do is we do the same as before we subscribe to this and we just log it so what happens is when you just run this in the console it will just go like this current block blah blah blah my balance and then it updates and then it updates you change the balance boom the balance will show the new balance and then it updates and it goes on so this is an observable and well yeah that's our xjs like this is not what we built this specifically we just built on top of this and and this is awesome that's why we we use it so like just I said is like it's actually extremely simple we did not go crazy with the amount of things we want to support we actually just support what we need and what the community up to now has told us they need so we have 12 functions and that's it right we have like super basic things the block number you know you can post transaction post road transactions already signed transactions you can get some contract you can get you know like my balance the version info of the node and stuff like this so just to see an overview of the differences between for instance web 3.js and like just so the account management the way it's done no sorry they are asynchronous management with web 3.js you would use promise we use observables the coverage of the RPCs that we that we support we keep it very very simple right and if you need some more please just let us know and of course and this is the very important thing like client like just is built the way we have it in mind is it's built to be used on top of like client and it brings a lot of things that yeah that do not comes embedded in web 3.js and I'll talk about it right now so so behind the scene like just uses the least possible resources on the like line so what you gonna do today just before I showed you okay what's the latest what's the latest header for instance or what's my balance for instance your balance will not change every second right the block number the block time is 15 seconds on the theorem does not make sense to just bother the node you know every second on 500 milliseconds right today you can do that with the theorem but it does not bring anything so light client the light.js library will do this for you right we'll actually get just a push notification will not have pool so you will get the the latest information when it's there not when you ask for it because sometimes developers just don't know everything and that's fine and that's why we wanted to build light.js this way so it fetches states on your head and not whenever you want so it just gives you new information whenever there is new information actually. It handles the subscriptions to the node for you it handles cache and it keeps the amount of network calls to the minimum but to the I mean it's still it's still there's you know you won't be like outdated you won't get outdated information it just does the thing like in an efficient way right so our goal and the reason why we built all of this our goal is to embed light clients everywhere as much as possible and to facilitate a very mass adoption while maintaining decentralization because we do not want to to just trade this off right so because of this we you know probably parity has built a node and this node can be run as a light node as a light client the thing is we wanted to use it and to see how things work and we wanted to embed light let people embed light client everywhere so that's why we built feather so feather is an application on top of a light client and I will show you just I'll show you in a minute I want to just talk very briefly about the stack so just like we said before so we have you act UI in react we use light.js to interact with a light node that is inside an electron app and all this app will interact with directly with the term network without third-party service in between so truly decentralized wallet is what feather is it used to be not the only one because mist used to be also using a light wallet unfortunately it's not possible a light client sorry and for students it's not available anymore due to other reasons so to my knowledge feather is the only application unfortunately on top of a light client so it uses light.js as I said it's bundled with parity of theorem light client and it sinks in a couple minutes depending on the Wi-Fi we have other interesting libraries that you might want to see one of them is called parity electron it's a small library to start and stop parity of theorem from a node.js environment and you will see the UX and everything about feather right now so here I just launched feather and this is what happens at the bottom you will see that it starts sinking right now and it just shows you you know like and shows you the how far you are and shows you an empty page because you have no account so I'm gonna check create a new account this looks like a green cat so I'm gonna name that green cat you know and now it's getting synced you know like at the bottom you can see sometimes so we show the you know the mnemonic blah blah blah you have to be careful with the mnemonic please type the mnemonic again and then you're gonna have the password and just to secure your account and it's sinking in the in the in the background so it's you know it's not extremely fast but it's alright and I can also for instance important account using I don't know adjacent so here my window was a bit not on the right side but I'm just importing adjacent and just shows you know the name and stuff and yeah so by the time I'm done with this process actually I'm done sinking you can see it it's synced and now if I click on an account it takes a bit of time to get the balance again it could be super quick this Wi-Fi was not like awesome okay now it's dated and I have near C20 token as the other one the other balance so here for instance I can add I don't know another token so it's gonna be a fake token it's my token so it's just tip coin and yeah you know at some point it just updates and to send a transaction so I'm just gonna click on this one and I'm just gonna you know say to whatever these amounts I can select the amount of way so here it does some call right it does like okay how much this transaction is gonna cost etc does some calls in the background and then right you send us a transaction like nothing nothing very right so I'm just gonna cut this because it takes some time to send the transaction but you you get it so what do we do now with this application so it has been audited this is the first time I say it actually it has been audited this summer by Trail of Bits I'm super happy because there was no big critical problem found we fixed actually all the problem now and we're gonna have a release probably next week with everything fixed and we want to give this to the community if anyone is interested to actually keep this going because this is not something we're gonna go further on we do not have the bandwidth for this and yeah so if anyone's interested please talk to me and we'll be happy to to yeah go on with with feather because I have a bit of time I'm also having a shameless plug here we're hiring a full-stack developer we have awesome other stuff to do with the light clients with many many things and please yeah talk to me or anyone apparently that's about it we have a couple minutes for questions thank you so much and yeah if you have any question