Making dApps feel like apps: Best practices for using elastic sidechains with Christine Perry
ETHGlobal·Fri, Oct 9, 2020, 12:00 AM
Making dApps feel like apps: Best practices for using elastic sidechains with Christine Perry from SKALE Labs
Transcript
so my name is Christine Perry from skel labs and you most of you have already met easy right yes well this is one of the bounties so we're gonna tell you how to win one of these bounties and some of the other cash prizes too because let's cut right to the chase we have bounties that you can win by hacking on scale two of them are for one thousand and six are for five hundred each now how do you go about doing this well before getting into that I want to talk to you about the problem that scale is looking to solve here and why is relevant to you at the hackathon and at scale one of the things that we're looking to solve is a scalability problem which to us maps directly to a usability problem one because most of you that have already hacked on etherium you've already ran into the issues of transaction costs storage costs and of course speed being an issue now this is also going to be an issue with the hackathon because as you can imagine as you're hacking every time you have to test something on rinky or another test net it's going to take forever to deploy you're wasting time and with scale not only are we solving these problems in the real world we're also solving these problems when you're just hacking and testing out your solutions to begin with so what does this mean how can you get around this today well typically what you can do is you can offload computation to a centralized server you can offload storage to a storage network such as IP FS you can wait for ether to 0 or you can use elastic sidechain now before jumping into the code I want to also show exactly how our network works because I think it makes more sense to conceptualize it before actually hacking on scale and just like aetherium one of the things that we do is we have a network of many nodes within our system and what happens is we are grouping together a subset of these to create your scale chain and your scale chain is not shared resource for anyone else that's hacking on scale as well so what do you get with a skel chain well you could deploy your smart contracts directly the scale that are written in solidity or you can use file storage if you're familiar with ipfs it's a simpler setup where you can just use an NPM package to get started and let's say you still want to talk back and forth to aetherium well we give you the option to be able to do that now as I mentioned the scale chain is just yours but based off of how we've created our system multiple nodes can run multiple scale chains as represented here so over time what you'll have is a crossover of scale chains on each node and Jack he has a section tomorrow on this he's a CEO of skill labs right there and he's going to explain more about the node architecture so today I'm just going to give a high-level overview of what that's like so one of the things that we also want to do is make sure that developers as a developing long-term on scale they're not paying for more than they need at any given time so you're able to grow with us if you are just testing out your idea or prototyping you can start with a small chain now what does that mean it means you get less transactions per second and less storage but it means that you're only paying for what you need at that given time and when you want to upgrade to a medium or large chain to go all the way up to two thousand transactions per second we're able to make that seamless transaction for you so because we're at a hackathon though I want to get into the code really soon and show you exactly how this works but before that one of the things I want to highlight is how easy is get up and running so most people if you've already deployed to aetherium you've used web 3 or ether ojs or something similar and put a connector to that using an Fuhrer hour or some other endpoint well it's the same process for deploying to scale you don't have to change anything in your code unless you're using truffle you change two lines and you deploy your smart contracts directly the scale and said so what you're able to do is offload some computation directly to our scale chain and have it run a lot faster and also a lot cheaper than it would otherwise run on theorem now one of the things that we talked about earlier today was that you can use entertain messaging and what that does is it gives us a direct connection to a theorem so in that instance where your tokenizing your application are there any developers in here working with ERC 2721 or anything like that okay we have a few we have a few well a lot of those tokens you typically want to leave on aetherium and what we do is we create clones on the squelching side which are then able to transact with without having occur any sort of gas costs but then when you're ready to exit you can exit from the scale chain we burn that clone and then you're able to free up that that token back to the main user so this essentially is what it looked like you have your smart contracts typically you'll have more than one you can deploy it directly to aetherium and then whenever you will like you can interact with it they are --there IAM and send the token directly back to the user so let's show you what all this looks like in the code so i'm going to switch over here and one of the things i want to do is kind of talk about this application that we thought it's a simple application it's called rock-paper-scissors what you're able to do is interact with a smart contract called rock-paper-scissors written a solidity and basically execute transactions directly on the blockchain so right now I'm using meta mask and with meta mask is connected to rinkeby now everyone's familiar with this when you actually click a transaction and you want to execute it and let's go ahead and do that together let's select rock we have this Gatsby for just doing a move I'm going to go ahead and click confirm and wait and waits and waits because this is what you have to do when you are developing on a theory on ethereum or rink B you don't get the transaction back in real time now as a game as a gamer or someone using this application this is not the experience that I will want or the experience that I want to create for anyone right so this is going to take some time to come back but when it does out there we go the user is then able to go through and continue the game now imagine doing that with more of a live-action game or you know a game when you're playing and gets component you would have to wait 45 seconds or longer before the transduction comes back and it's not a good experience so let's switch set up now at scale what we did was we create an easy way for you to get access to the scale chains so if you just go to scale Network /f Waterloo that will redirect you to a place where you can fill out the form and get access to a scale chain right away now with that our documentation gives you a quick getting started guide for how to get up and running it's a one two three step process you get your scale chain well that's super easy fill out the form you migrate your smart contracts changing just two lines of code if you're using truffle just two lines of code and then you execute transactions using web 3 so as you can see not much is really changing for you but what you're gaining at this hackathon is save time and I'll show you what that looks like in a moment but before getting to that let's switch over to the code and show you how easy it is to actually make this change so most people are familiar with what this looks like let's go ahead and add another line for scale and I cheated a little bit I already have the scale chain ready so I'm going to go ahead and plop it in here and then because it's just like deploying to rinkeby I don't really have to think much beyond just copying what's already here pasting and just changing again a few lines of code and that's it that's all it requires for you up and running with deploying to scale I'm officially running one of the bounties including easy so what does this look like in action and what I want to do is show you a direct comparison of deploying to wrink B versus deploying to scale so truffle dot deploy reset Network wink B let's go ahead and let that run and this is going to be a very similar process that we're all familiar with one either we will get an error or two it will actually execute it looks like yep extra comma thank you thanks for the Co coding back there alright so here we go let's go ahead and wait and again because you were only limited by time here at this hackathon you have what less than three days waiting each time you make a change your smart contract for it to deploy is not a good experience so we'll let that run in tandem and I'm going to have another window open for the exact same project and this time just to fouetté to scale now we'll put this side-by-side it's that way you can see but essentially while we're still waiting on the first transaction of the first smart contract to deploy scale in real time is able to deploy my three or four smart contracts and near-real-time so you're saving a lot of time here at this hackathon but more importantly let's go here and we'll go ahead and start this again I'm going to go back to my application and let's switch this up instead of interacting with rink B we're gonna interact with scale and here let's give that some time to refresh who wants to play with me now what moves it we select scissors all right good move so one of the things you'll notice is that scale doesn't introduce the idea of gas for end-users why because a lot of times it doesn't make sense for them to have to know about it they just want to play the game but more importantly instead of having to wait you know 45 seconds or however long it took me to talk my way through returning a transaction we're able to get it back in near-real-time so not only are you saving time by deploying to scale and testing out your idea here you're also saving time each time you want to process a transaction and near-real-time which is currently not achievable today I just rink me alone so what we're able to do here is give you an option of being able to use all the same tools that you can with aetherium on scale but beyond that if you look at our documentation we have other really cool things here as well such as being able to use file storage now file storage we package this up pretty nicely in an NPM package which means that you can just use JavaScript to interact with a blockchain so if this is your first time interacting with blockchain technology you don't have to dive directly all the way in you can just start here and start to upload and download files directly to the blockchain and we've done it in a way that's more or less like an EM and API to give you access to those files that you're storing and these files can be as simple as an image or as complex as a train model for machine learning now the last thing I want to talk about before opening up for questions is partnerships because one of the things that's apparent in this face just like in any other space currently developing on a web 2.0 is that you typically can't build an application with just one technology right you have to layer them on and we encourage do the same thing here we have great partners with Portus Taurus pits key terminal and maker the top three at the top what they do is they allow you to have a better way to onboard your users so instead of your users having to worry about using meta mass or downloading meta masks it's an API based approach where the DAP developer codes it up and suddenly you're able to add a button just like a Google login or facebook login directly to your application it's a lot simpler and a more user friendly flow for your users portage is here today so definitely drop by and you know talk to them the next one I want to talk about is one that I recently fell in love with terminal they allow you to be able to actually debug your code in real time because if any of you have ever tried to bugging a blockchain application it is a nightmare reason being is because you have to remember have your console open if you don't you lose a transaction if you somehow you know closed down your application you then have to figure out a way to then you know cue well go through all the event with terminal what they do is they give you an API approached where they're able to keep track of all those those transactions for you and so you don't lose anything you're able to log into their portal and see everything that's happening in real time and historically as well now I just want to wrap it up with the bounties again because one of the things that I just want to make sure that everyone's aware of is that and we do have bounties here at the hackathon including ithi so please please try hacking on scale and let us know if you have any questions we'll be at the booth today and tomorrow and also on our discord any questions about anything No yeah good question so yes with meta masks meta mask is a way where the end user has to take more responsibility about being able to switch between networks so they have to switch to rink B they have to switch to Cove on they had to switch to whatever network you're currently deployed to to use a transaction and the same thing goes for scale it doesn't change now this is where it comes in handy to try out one of those API integrations that we were just talking about such as Portus or bits key or tourists because one of the things they allow you to do is code it directly in the backend where the end user doesn't have to do anything and the API base wallet is able to just make the switch for you as well as create the wallet and maintain all of that so yeah immediately today really today well one of the things I think if you come to our desk all of our flower all of our flyers has the you know website to actually get the scale chain from so come pick up the fire get the website to the scale chain and you'll be able to get one and directly on your own so what we do is we set up nodes or servers directly on our side to be able to run the consensus because one of the things I highlight today that Dec will go into more detail tomorrow is that we have a consensus protocol that runs and finalizes of transactions it's layer it with BLS signatures and a whole lot of other really great cryptography and math but that is actually what is running the transactions and actually adding into the blockchain so for the hackathon it is four nodes that's doing that but when you actually get a scale chain as a doctor fellow pro that's applying you know it's production it's going to be 16 nodes and so those 16 nodes will rotate over times that way over time essentially all potentially 1,000 nodes within a network of work for your application all right well thanks for your attention guys and yeah feel free to drop by the booth and get a skull chain [Applause]
Automatic transcript — names and jargon may be misspelled.