Christine Perry + Stan Kladko ~ Run Smart Contracts on Layer 2
Ethereum Denver·Wed, Oct 9, 2019, 12:00 AM
Speaker
Transcript
[Music] hello guys I am staying I'm the CTO of scale libs and I'm Christine director of solutions engineering at scale labs and we're here to talk to you about running smart contracts on layer 2 but before beginning we were first like the level set and talked about the problem the solution and how it actually works deploying to a level 2 solution like scale and then we'll get into the code so Stan can you help us understand the problem yeah so you all guys probably can program in solidity right we all love solidity in fact in fact all of you are here probably because you know solidity you know solidity meta mask you know remix travel all of this stuff is something that all of you like right that's otherwise you wouldn't come for this Krakatau so we have this thing where like thousands of people around the world know solidity travel or anything and they'll have a zero but we don't see many d apps actually being commercialized we don't see many success success stories in the apps so there is this disconnect where lots of people are doing lots of things they're all these hackathons and stuff but very little things actually get to be commercialized to get real success and the question is why this happened and the most important problem is scaling and scaling itself get several you know pieces one of the pieces is transactions transaction cost is high on ETH you pay like 10 cents or more the transaction can go higher due to market conditions and also storing things is expensive right you want to store like 1 256 bytes you pay at least them u.s. the US so both storage and transactions are expensive and that actually creates lots of problems for the adoption so it's crazy to think that today you have to wait 40 blocks or 10 minutes before you can verify it transactions being finalized and it doesn't matter if it's in transaction or storing data so what are some of solutions that we have today to tackle this problem okay they're actually several solutions several obvious ones right the one which many people have been using if you don't have enough computation on blockchain you just do it on a centralized server right so many people in the past did this stuff for instance is a delta right lots of things on this Delta happened on a centralized server cryptic hitches and all that was it people but the problem is if you are you down low you actually outsource your computation to a centralized server you essentially break the idea of blockchain and also you break the security of blockchain so this solution is the most advanced but it's very insecure now as far as storage is concerned there's another solution there are storage networks one famous storage network is file coin and several years from now we'll probably see the storage network so if you want to store lots of stuff you'll be able to use things like file Queen but these things are not available now and coming maybe two or three years from now then obviously very obvious solution is just wait for ETH 2.0 everyone knows ETH 2.0 is great you know it's going to provide lots of transactions lots of speed but again having the current plans you have to wait like several years before ETH 2.
0 becomes reality and finally the Ellucian that we're working at scale is a side chain so it's a layer something which is called layer two because it's a separate network and it's a separate block chain which is securely connected to the main net and is still decentralized so it still executed by independent people and has all of the advantages of a real book chain so then how does this actually work Howard an we actually use a layer 2 solution so first of all it's defined what a side chain is a side chain is a fully decentralized block chain so in a very similar way to a real block chain to a layer one main net a side chain is executed by nodes by independent people so these people form a side chain as a GIF developer you get your own side chain on the network so you don't have to share it with anyone if you have a side chain in all of the resources of this side chain belong to you so you have you get free and inexpensive transactions and fast transactions and ultimately the side chain is securely connected to the mainland so essentially you have two components you have to have the main net and you have the side chain and your application is deployed post the main net and to the side chain can you explain more about what's going on here ok so a little bit later Christian is gonna show a demo but really the most important thing to know is that you all guys know web Street trails right web Street race is a library that all of you I hope used to connect to the blockchain right in our case since we have the side chain in the main net there are two versions two clones of our web series that you run on your browser so instead of running one copy one instance of web CJ's Iran two instances one points to the mainland and one points to the side chain and then most of your application is deployed to the side chain for instance if you have a game all of your game dynamics all of the moves all of the stuff is getting deployed to the side chain where things are free almost free and fast and cheap and then pretty much the only thing that you have to keep on the main net is where you accept money where you accept your seed money tokens so we have a special contract which is called the deposit box so if you want to accept a RC energy - on a token this token is frozen in this deposit box contract and the same amount of glooms is created on the side chain so the entire thing about transferring money from the bayonet to the side chain and back is becoming the process of this clone creation where froze money on the main net you create clones on the side chain you have to rate those clones the clones are fast and easy and speedy and then at some point if you want to exit you actually destroy clones on the side chain and the corresponding amount of tokens is unfrozen on the mainland big connection between the side chain and the main net is secured using a cryptographic technique which is called Billis signatures of threshold signatures we are using some other projects are using it you know Definity uses it so threshold signature sibelius signatures is very neat mathematical probe for an object which allows you to secure interaction between two block chains and finally what's also really great is that all of this interaction between main net and side chains is made fully automatic so we provide this machinery to you and if you want to transfer money from the side chain to the main net and back you don't have to know about all of the technological details it's very easy the money is simple simply is frozen on the main that created on the sidechain and quick all right thanks Dan so now let's look at the code to see exactly how you would make something like this happen before getting into the code though let's first take a look at the dap and bear with me just a moment okay so this step is currently connected to rink B right now it's running two smart contracts one for authentication and one for rock-paper-scissors which is a game that will all play together later but to show you just what the speed looks like let's go ahead and sign up and this is something that you're probably familiar with metamath will open it will connect to the blockchain and then you will actually see the transaction come back but one of the things that you'll notice is that it does happen really really slow so we won't wait for this instead let's transition to the code so we can see what changes would look like for deploying to to point to a layer to solution so I have my back here all my store contracts like already built and I've already gone through that process that you would typically expect I have my local ganache solution here I have rink B but I've already deployed too as well so what does it take to deploy to scale or layer to solution well it's really quite simple I'm gonna go ahead and cheat a little bit and copy this rink B network module let's give it a proper name and let's also go ahead and cheat a little bit copy this ganache one give that a name and now what we'll have to do is connected to an IP or n port that connects to your own destiny that you'll create or will create for you so in this case I'm going to go to our dock you eye and pull that up one of the things we're also building on our side is adapt UI to easily understand how to create and manage your s chains so I'm going to switch this over to our private network so I can see a man get that s chain now once this loads what you'll have access to is your s chains and all the RPC ports it looks like all right so it looks like we're having some internet issues but no worries we'll switch to our own private one in just a second here bear with me just a moment guys all right so let's refresh and try that again okay Internet issues resolved we now have our s chains crisis averted so if I click on this Gale workshop here the RPC endpoints will appear and what I'll be able to do is simply copy that into my truffle my truffle Jas script so imma go ahead and copy this first one here and paste it here now it really is that simple if you're wondering what some of these other things that we're using we're using anomic because you have to sign the transactions even if you're doing something as simple as deploying contracts if you're not familiar with getting that how you get that as you go to the meta mask and you're able to retrieve that from your settings here so just go to settings scroll down to reveal your C words and that's where you'll be able to get your monadic okay so now that we have all the pieces together let's go ahead and give this a try and actually run this deploying my smart contracts to scale so I'm gonna use truffle again truffle deploy we're gonna reset because I've deployed this once before when you use a network for scale and let's go ahead and just compile them all again anyway alright fair of me just a moment now the typical process you'll see it's going to compile all the smart contracts and then go through the typical deployment again this is something that you're already familiar with this has been done before with your local and rinkeby test net but doing it with scale is a very similar process once that's all deployed and done we can then go back and actually test our DAP to see if it's working so let's give it a few more moments here but while it's doing that I'm gonna go ahead and set up my meta mask to also connect to my scale chain so that same ip address import I'm gonna go ahead and paste that in here for connecting go ahead and reset just in case there's any non sis use going on alright and let's come back here to my demo application and let's go through that again so if I sign up same process we're used to meta masks one of the things you'll notice is the transaction comes back extremely fast there's no waiting there's no waiting 60 seconds forty blocks ten minutes and we're able to proceed to our game and play so who wants to play with me love it okay so what should we select paper okay paper it is so we're gonna go ahead and play this game it's again it's a smart contract that we deployed to scale and similarly what you'll see is in real time we're able to process that transaction so by using a layer two solution you're able to speed up your smart contracts whether it's computational or you're dealing with transferring money you're able to handle them both within our platform now because it was a tie we'll play again anyone else Rock so just to see it one more time because it was too fast let's go ahead and come here and confirm these transactions it looks like we didn't win that one either but to wrap it up one of the things we want to make you aware of is that we do have a couple of bounties out one for the rocky scaler so if you decide to hack with us here at this hackathon our number one bounty you'll receive two thousand dollars for creating a creative app that actually needs scalability in addition to that we also had three runner ups I'll each for 1k each and those are also the same qualifications creativity over over I guess having it finalized but we really want to see exactly how you are actually going to use a layer two solution to speed up your smart contracts so now we can open it up to Q&A but before that the last note here is that if you do want your own s chain to run with please join our discord channel make sure to distribute that to you so any questions all right sounds great [Applause]
Automatic transcript — names and jargon may be misspelled.