Private Ethereum Interchain in minutes on your blockchain platform.

hi I'm Dean Shelton director of engineering at Dragon chain I wanted to show you how you can use smart contracts on Dragon chain to get your business logic onto a blockchain it's actually pretty straightforward let's just jump in and do it I have a chain here that I built out it's a level 1 Dragon chain I call it a demo or Die and we're gonna put our own business logic on here that's gonna read from a private ethereal Network pull the data into a contract do some business logic and then push it back out to the private aetherium network so in and out with our business logic in between pure blockchain and we can do it with docker I have here on my screen this is a typescript nodejs contract but really you could write this in whatever language you want you could write it in a single line of pose Excel probably Java scripts a little verbose but this will get the job done you can see it pulls in a found ëthere ium transaction and this will just be an array of numbers so it'll end up looking sort of like this 1 2 3 and it will add these numbers together using an array reduce and then you know it should output the result of the sum of this array and that could be an array of any three numbers I have a script here that's going to generate that on this private aetherium network you can see three numbers randomly between 1 and 9 and it's gonna send them to this address with no value no eath but just as a data transaction so I have a private aetherium network already set up let's just ssh into it it's private aetherium node this is just on an ec2 it's running death and you can see this is the guest node just mining away doing it's doing its magic you know throwing garbage out into the universe that's what's happening so we want to generate some traffic on this network and then have our dragon chain pick it up do the business logic and send it back out that's what this that's what this demo is going to be about so how do we get our JavaScript or POSIX shell or golang or you know ruby or whatever on to a dragon chain what's that process look like well there's a couple options for you you could use the user interface at console about dragon chain calm I'm on our staging site but you could just click on you know creates contract select custom and give it all the details for your for your docker container and once you push once you push create contract it'll just pull your docker container in and run it but let's do it from scratch here this is the example interchain project that I'm in and we're gonna build and push this docker container docker build dot and I'm gonna call it something I'm gonna push it to my own repository on docker hub I'm gonna call it booyah so I'm gonna just build this and that should go okay and I'm gonna push it up okay yeah all right so now my docker container is sitting there on docker hub ready to be used on a dragon chain so what do we do to actually get that onto the dragon chain well you could use the UI right here or you can use D CTL the dragon chain command line tool to add your contract and I like to do it because it's you know really turnkey and easy but you can see I'm already connected if I say D CTL status I have my keys plugged in and I'm talking to my dragon chain with an ID of this now this is a demo or die chain so let's let's add our contract here so I'm gonna just say D CTL contract create and I'm going to call it business logic and I have to give it the the docker URL which you know might make this a little bit bigger here so this is at docker AO / gene Shelton and one three boo-yeah yes poet right oh yeah yeah I was booyah oh yeah right that was it yeah that was it okay so yeah boo-yeah latest and then we're going to tell it how to run it this is a node.js application and it runs at a p– dist index.js this is just the start command for whatever container you use and that's that's pretty much it that's all you need to give it and this should create my contract you can see the business logic contracts being created it's pending right now so if you were to go to the UI you could actually probably see it they're getting built out let's go to the chain details page and refresh and there it is boom okay so it's active it's actually are you ready so cool so now we have our business logic on the blockchain from a docker container i was pretty straightforward now we just have to feed it information from the etherium network and then allow it to publish that information back out and dragon Chan has two really easy contracts pre-built to help you do this there's a watcher container and there's a publisher and you can go through the contract creation process here and create the watcher really straightforward just give it a name doesn't really matter what it is tell it how often you want it to run tell it what address that you want it to watch in this case we're gonna be watching we're gonna be watching this address that I'm going to generate traffic on which I hold the private keys to and yeah we can fill all that stuff out here or you could just use the DC CTL command which is really easy so I'm gonna do that create the watcher and out it goes and the last piece is to build a publisher and you can also find that in the theory Impala contracts you can even tell it what private network you want to talk to maenette rob stone custom Morden I mean this means you could use a contract to to read from one aetherium chain and actually publish to a different entire aetherium blockchain or if you wanted to make a publisher for a different network you can even publish to Bitcoin or neo so that's kind of cool let's let's just shortcut it and we're gonna use DC TL to create the publisher it just is the dragon chain publisher container with all the information that it needs to talk to the private node which is just this so here we go copy this and create that okay so now we have three contracts out on my dragon chain and we're gonna check them out let's see if they they've loaded yet so we've got to the third one should be installing right now okay one more all right so after we get these things up and on our chain we're going to tail the logs let's see if they actually get created so show me potato salad alright it okay there it is publisher here we go okay cool so we have a watcher business logic and a publisher it goes in that order we watch things on a private network here and it's going to feed information to our business logic and that's going to go to the publisher which sends it back out to the blockchain let's set up some Watchers and tail these logs so we can actually see it happen in real time we have the blockchain happening right here this is just a private aetherium so we're going to create a pipe to our contract so let's just watch this thing happening this is the open forgot this this is the watcher contract cool so you can see it just running here that's watching the ethereum blockchain happen over here I'm going to grep the output here so we don't see you know that verbose output and just do grep when it finds something and show the last there are the 10 lines after that okay so we have that grep running now we're going to tail the logs for our business contract and I'm gonna clear this thing out and we can link it to our contract here this is business logics contract ID cool okay no output yet that's good it hasn't been triggered so lastly we're going to tell the logs of the publisher over here so ok and to do you can also look at these logs in the dragon chain console they're available by just clicking the log button and refreshing that log stream but I like to do it on command line because I'm just more developer-friendly I suppose so now all there is to do really is to submit traffic on the network with this you know create transaction endpoint and we should see that go out to the network let's do that now so I'm going to run that script you can see we created a transaction with the numbers 2 3 & 6 and the etherium node takes some time to do the block but once it creates a block it goes all the way through this this log here is the publisher transaction so you can see it actually published out to the a theorem network which in our case was that private note here this address and this is the transaction hash so let's see what that looks like I have a block Explorer for that private aetherium node just sitting right next door to it if we look at its transaction it published this data which is if we go here and translate it from hexadecimal to utf-8 you can see that we linked the etherium input hash here so this is actually a hash on that same network with the new output hash which we just looked up and it has two three and six outputting eleven so that's our business logic exposing just what we want on the private etherium network input output private nothings public and out it goes at this point this transaction has now been recorded on dragon chain so it's going through the five levels of consensus and everything that we've just done is Ledyard on the blockchain so a pure blockchain solution that enter chains private aetherium and you could really do this with anything I guess that's it thanks for watching yeah happy coding

Leave a Reply

Your email address will not be published. Required fields are marked *