BlockApps STRATO

Devcon 1 · November 2015 · 35:41

Victor Wong, Kieren James Lubin and Jim Hormuzdiar present BlockApps STRATO, a full-stack technology solution for building industry-specific blockchain applications on the Microsoft Azure cloud. The Devcon 1 session covers how the platform packages Ethereum tooling and infrastructure for enterprise developers.

Speakers

Topics

From Devcon 1, hosted by Ethereum Foundation.

Transcript

[Music] So, I'm Victor Wong, one of the founders of Block Apps, and I'm here to introduce to the world block app strat on Microsoft Azure, the easiest way to build blockchain applications. You've seen this comparison made countless times. Bitcoin as a blockchain we know is limited in functionality and thanks to Vitalic and the work of the Ethereum Foundation and ETHev we now have a completely new global computing platform.

But because of that the success or failure of almost any computing platform is actually based on the number of applications that are being delivered on it. So Black Ops has a simple mission. We want to be the easiest way to build and deploy blockchain applications and businesses on the Ethereum platform. We're the team behind the Ethereum Haskell implementation. And we want to be able to provide the facility to easily deploy private blockchains, but also have these blockchains be able to communicate with the public blockchain.

Lastly, we want to make sure that applications built on our on our platform can communicate with existing systems and devices. In a sense, what we want to provide is a bridge to the existing world with Ethereum. But here's the challenge. Now, many of you know all these terms. You know what this entire ecosystem is about. But I can tell you when you show this slide to regular people, they are terrified. They have no idea about where to begin because truly the Ethereum ecosystem is not just one tool but a series of interconnected technologies and tools and you have to understand the entire

picture to really be able to maximize the use of it. So many people come to us and they say well where do I start? Where do I begin? And that's where Block App strat comes in. Basically, what Block App Strato is a full Ethereum blockchain as a service framework that gives you everything you need to start building blockchain applications today. That goes all the way from spinning up your bone blockchain, a middleware API connector, wallets, faucets, everything you need to build and deploy applications. and we're going to show you a live coding demo by one of my co-founders, Karen James

Lubman, our chief data scientist. Okay, thanks Victor. Okay, there we go. Let me um maximize this. So, uh, first thing I'm going to do is actually launch a live, uh, instance of Strato. It takes a minute to spin up and we've got network latency. Then I'm going to go into one of our demos. Actually, we have to pick exactly what I'm going to code.

I've got about five minutes to do it. Can I make a suggestion? Sure. So, Karen, since we're partners with Microsoft now, I'd like you to change our revenue sharing agreement. So add Microsoft into our company and let them share part of the revenue. And I'd also like to make sure you have five minutes, right? Yeah. Make sure everything you write can run on any internet connected device, including a mobile phone and any browser. Okay, got it. Let me fire up the instance. No problem. All right, starting the deploy here.

So this will all get listed on the marketplace soon but uh this is the block apps login for the moment. Let's call this strat dev. We're firing up. All right. Looks good. Let me go go into the contract. So, I'm about to show you a command line tool called block.

These are the commands it supports. And what I've set up here is a scaffolded uh blockchain application. Kind of looks like a web app. You can see we've got HTML, JavaScript, CSS, an app.js to run a web server. We've got a contracts folder. And in the contracts folder, we've got some standard solidity contracts to get you up and running quickly. So, let's take a look at what's there. A couple samples. The payout contract is the contract that Block Apps has been working on. This encodes the revenue split or the the the ownership split between Victor, Jim, and I. And we're going to cut Microsoft in

in a moment. Let's look at our instance. Looks like it's almost ready. and show you the code. Okay, very simple solidity contract. Three addresses, Victor, Gemini, ownership distribution, a setup function uh in which we split the equity and a dividend. Let's see how we're doing here.

It's almost ready. Okay, good. So, now what I'm going to do, I'm going to cut Marley in. Let's give Marley the address with four C's. And because he's been so kind to us,

we're giving Marley 70% of blockouts. We have to talk. Got to add a line here. Normally I don't roll over like that in negotiations, but okay, looks like we're good to go. I've set the URL up already.

So, what we're going to do now is compile this contract. It's a command called block compile. Okay, that looks good. And let's go visit our web server. So if I type block start, this launches a local web server and we'll just see what our contract looks like. So that's a localhost 3000 and pay out. So what Block has done here is scaffolded a user interface uh for this contract. It's automatically generated and we can see that hey we've compiled the contract but I don't have a wallet yet and I still need to upload the contract

make it bigger. Yes. So block is here to guide you through the process of creating an application. It'll remind you about things like deploying contracts or when you need to upload a new version of your contract after it's been uploaded up updated excuse me. Okay. So, I'm going to go ahead and generate a key. Got network. There we go. Now, I'm going to go upload this contract.

All right. And I refresh this page. You see it has an address. Now typing the password in. We've got some data in storage. You can see these addresses have not been filled in because we haven't called the setup function just yet. Um I have about a th000 ether in the bank. The contract has zero ether. So going to send the contract some ether and do the setup. Okay. You can see that Marley now has an address as does Victor Gemini and the contract has 10 Ether.

So, here's Marley's address. There's nothing at it. This is actually what we want. And I'm about to carry out the There we go. All right. So, if I check this, Marley should have a balance now. There it is. It's in way. You can see he got 70%.

We should label those units a little bit better. But there we go. We didn't need any lawyers. We set up the the revenue split. They're the back. They're at the back. They're the back. Ah, well, we let them in for this conference, not the next one. Anyway, so that's how you can get up and running in five minutes and build your first app with block on block apps. Uh Ryan later will thank you. [Applause] So uh block is a wrapper around block apps.js which is our uh every purpose JavaScript API. Um so block takes care

of the scaffolding and the onboarding but block apps.js you can drop into any project that you already have. So maybe when you do something more complicated you want to use block apps.js. Thanks, Victor. Here. Thank you. So, as you can see, block up straddle is designed for very very rapid deployment and development. Some of the key features are that it's designed for building uh customizable private Ethereum compatible networks. You do rapid deployment and infra on existing

infrastructure like Azer. Um as Marley mentioned coming soon in the marketplace will be one-click deployment. It has a restful API which is designed for integration with existing services and devices. And one thing is it scales easily from small private sandbox deployments into multiple consortium deployments and even elements of the public Ethereum blockchain. It's right once use on any network that you want. And all of this is built on the technology we developed for the Ethereum Haskell implementation. And to talk about that, I'm going to introduce my other co-founder, James Hermazdor, PhD

and creator of SSLVPN. Thanks, J. Thank you, Victor. So, uh, about a year ago, I, uh, uh, um, Karen actually contacted me and I learned a little bit about Ethereum and I became fascinated right away with Ethereum and I went out and started reading everything about it and I immediately wanted to uh, dig in and understand how it worked. And for me, the uh, natural choice of a language to use to work with Ethereum was Hasll. Uh I've been using Haskell for about five years now and it's uh uh over that time become my favorite language. Uh it's got

a lot of features that are uh extremely nice. Uh first of all, as you heard yesterday, uh Haskell is a functional programming language and uh the thing about a functional programming language is that the specification is the executable. the code that you write with Haskell looks a lot like the description of the code that you are uh uh writing. Uh second of all, it's one of the most strongly statically typed languages that exists. So, generally speaking, if it compiles it, it's correct. And I've had many experiences over the last year where I've had to make changes to the code and I've uh spent hours ripping it apart, rewriting it and uh and I'm uh

generally very surprised at the end of the day once it compiles it tends to come up and it just works without bugs. So um and third of all it's very performant language. Um so when you compile hasll it compiles to native executables and if you write your hasll code properly it can run as fast as C. So um generally speaking if you want to write something and you just want to make sure that it works and it works fast is your language. Uh and it's been as you can see here we put a few examples of um companies that have been using it in the last few years. So uh let me talk just a moment about the architecture of Strato. So Strato uh as

you can see it's from the beginning we wrote Strata to be fully um modularized and uh in the center we have a SQL database and uh around that SQL database we have many pluggable modules. Um, for instance, the VM itself is just one process that runs and it connects grabs the data out of the database and and processes it. We have all of our communication to the outside world, our separate pluggable modules. We have analytics that are occurring so forth.

Uh but the important thing here was we put SQL in the middle and we chose that deliberately because we wanted Strato to be a an architecture that would plug right into existing enterprise uh u uh environments today. So thank you very much. So what one thing about Strato and the Athereum architecture that we've chosen um that Jim has created is because of its modular nature, it's actually completely compatible with many of the existing Ethereum tools. You can spin up

a private network and also connect it to a GU node or C++ node. You can use front-end tools that are being developed all over by the community such as ether camp, truffle and embark. So really what what when you use straddle you're not restricted to only our tool set. Now the one thing is in order to really get a applications created simply having the technology is not enough. Education is a big piece of the puzzle and in order to accomplish that we've been holding a bunch of workshops. Um we call them zero to blockchain app where you come in for a couple hours you start playing around with the tools and you

walk out having built your first blockchain app. In addition, we've been actively involved in a series of hackathons uh co-sponsored by Consensus and Ether Camp. And without our prompting, it seems that our tools have now gotten picked up by other developers who found it's a very easy way to build a blockchain application. In fact, the recent winner of the Rise Barclays hackathon won using block app strat. And here's the thing, he had never looked at a single line of solidity before that hackathon.

So, what we're trying to do is essentially provide a complete solution. With Microsoft, we now have one-click deployment on the Microsoft Azure cloud. We're providing hands-on workshops and education efforts to make sure people can use these tools. And lastly, with our parent company, Consensus Enterprise, we're helping uh companies figure out how to build and use these technologies in the long term. This is our team. Um, come look for this t-shirt. We are very friendly and open.

We'd love to talk to you about how to use our tools and how to make our tools interoperate with whatever you're doing. So, the key message of all of this is this isn't about the future. This is about today. What can we start building right now? Thank you very much. Yeah. Okay. Right. And number

Go away. So, my Google calendar wants me to know that I have a a talk to you. Yes. Thank you, Google. so I'm Ryan Rich. I'm the author of the block apps.js JavaScript library. Uh block apps.jsjs connects Ethereum to the web. Block apps itself as Jim just told you exposes Ethereum as a database. Uh using our restful API, you can query any number of aspects of Ethereum uh both by

native metadata and by metadata that you can only extract by having run those transactions. Uh you can query blocks, transactions, accounts or account storage. And you can query thing those transactions by such such features as what accounts have changed in them and other such things that might be of interest as analytics. Block apps.js builds upon this API by wrapping it in highle JavaScript. Uh in fact it supports solidity uh very transparently. It wraps solidity contracts in JavaScript objects.

uh thus realizing the uh the programmatic structure of a solidity program as the programmatic structure in JavaScript so that you can easily integrate it into an application since any network communication necessarily is asynchronous. Java uh block apps.js uses a popular promise library bluebird uh to make uh to make these uh your interaction with uh with this asynchronous uh activity powerful and uh and comfortable.

Nope, there we go. Not done yet. So um let us now take a look at something that you might write with blocks.js. So oops this is a little bit too expanded. Here we are still large enough to see. Hopefully the color scheme isn't too dark. Is it too dark? All right. Well, I'm going to just attempt to power through this anyway because all

select what? Select all. Ah, very good. Okay. So, this is the HTML portion of that you might write with block apps.js. It's very simple and it uh just produces a little interface that looks like that. Just a box with a couple uh a couple fields you can fill in. Uh you'll notice that it's fetching its uh its JavaScript from the Strato Dev uh address. This is a Azure instance that we started up for ourselves uh where Strato is always running and this

library is available. All that happens when you open this uh this page is that it runs a function and waits for you to push the button. All right. So the code the solidity contract that is behind this uh behind this application is a simple crowdsourcing thing. Basically uh people can submit their names a little bit of either and they can get contributed to the contract and after a certain point they are uh you can just decide to pay it out. So this is not intended to be clever. It's just intended to be instructive.

Uh you'll notice that uh little way down I have this set profile option. This is uh one of the features of block apps.js JS that makes it easy to use different blockchains or uh or different strat nodes. Uh we have uh at the very least a strat live node in addition to a strat dev node and that is running rather than a sandbox blockchain, a live Ethereum blockchain. And by simply changing the word, let me just uh oops dev to live.

I could make it run on the live network. Now, it wouldn't be wise because I have decided to use an address that has no ether and I've also put its public key up on the screen. So, it better not have any ether. But uh if I had architected this just a little bit more carefully then uh just by making that one change it would in fact be a real a real DAP. So block fjs has a number of modules. Uh it has a uh it has a solidity module uh for one thing and that's the module you're going to be using the most often.

it has some ba uh some basic support for for Ethereum concepts below solidity but in fact solidity just abstracts all of them to a higher level so for the most part you're just going to be using that however uh as you'll notice in Kieran's contract uh you can sometimes find yourself submitting address uh values in way when you really meant to submit them in ether so uh you can in fact convert them back and forth pretty easily with the units module this faucet thing uh is a testing facility. Uh like I said, this address has no real ether on it. But on the test net strat dev, it uh doesn't need ether. Uh or rather it does need ether, but it doesn't need real ether.

But we need to give it something so that the uh VM will work. The faucet just supplies any address I want with a thousand fake ether. So let's change that back to strate so that I don't accidentally try to spend something I don't have. All right. Uh so let's go down and look at this code. So what's going on here is that it remembers the uh address of the of the individual who you are uh benefiting with your contributions as well as various information about the people who have paid. Uh as you can see this is a fairly

uh complex solidity structure. It's a mapping from addresses to a userdefined strruct. And the javas the block fsjs library actually does support uh interpreting the values of even such a complex object. Uh it reads the storage. uh it interprets the structure of this solidity code and it figures out what of the uh hexadesimal nonsense that lives in the Ethereum storage corresponds to the uh to the values you meant to put in there and it converts them into JavaScript types. So you don't have to worry about any of the implementation details of Ethereum uh when you're working with lockupsjs. It does as much

as possible to uh to take care of them for you. So when you create this contract, all it will do is store the uh is store the name of the or the address rather of the person who's supposed to get the money. Uh it also initializes that array of uh of contributors and then when you contribute oops all right so when you contribute it uh well it does a little check to see if you haven't given anything but otherwise it simply adds the contributor to the end of the array uh and adds the value to the uh to the strct corresponding to that contributor which lives in the

mapping. then and then then it tells you that the transaction succeeded. So if I were to uh if I were to try to give some ether to that right now, say myself 10 ether, then you would expect to see something pop up and it does in fact pop up. I have uh I've been generously for giving 10 ether to this person. So how did that happen exactly? This is where block apps.js uh actually does its work. So at the beginning of the at the beginning of this this app before I even came here I loaded this page and it created that

contract. All I did was I took that code I plugged it into the solidity module and I called the new contract method. Since most of these operations are asynchronous the call looks a little strange. you would expect it to be a member function and it is but it's a member function of the return value of a promise. So I'm using some promise syntax for that and all it does is it creates a contract and saves that contract in the uh in in the uh in the page for for later reference and it also activates that button since there was no error I don't care about the other function.

Now when I push that button, it uh went through a long chain of promise operations. The beginning of which was to run this function which I've called patronize. Uh maybe I should have called it contribute. Uh so let's look at how that works. That's based on these three functions. So the core the core piece of functionality is the second function there patronize which takes a name and a value the things that appeared in those boxes. So all it does is it takes that contract object which is perhaps not creatively called contract looks in its state which is a subobject which is

automatically created by the library and in there it finds a method called contribute and if you remember back at the solidity code that was the method in the solidity code it's named the same thing and it's only natural that it should in fact be a function object in JavaScript. So that thing takes a variable which is the same argument as it would take in solidity. And I can also specify that it sends some other stuff. Uh in the transaction parameters TX params I can specify a value which you'll notice that I've specified in ether and it's pretty clear that I meant to specify it in ether from the syntax.

I could also have said gas price or gas limit if I wanted to, but I don't particularly because those are implementation details. And uh the profile back up at the top, which was set to strate also has some somewhat permissive defaults in the case of strat dev and in the case of stratol live, somewhat less permissive defaults that seem compatible with the other with the existing uh Ethereum clients, GU and C++. uh so that the transaction will likely be accepted and you don't have to worry about it unless you're really concerned with the uh the fine the fine print.

After I've set all that up, I just call it from uh well something I need a private key and uh the private key in this case is just being created on the fly from a library from a a wallet that I have uh I have spun up in the page. This is not a very secure wallet. It just every name it takes it randomly generates an address for it. Uh and then with the fund function at the top of the screen, it uh applies the faucet to that address and gives it a thousand ether. Uh once it has the address, it has the private key also and it just sends that into the patronize function and uh and and submits the transaction. And that

was what you saw happen here. Of course, what you haven't seen yet is actually uh obtaining the values that are printed. Aren't very many values, but something had to be done to get them. So, this is where the placard is printed. Uh this is where the contents of the contract are interpreted by block apps.js. If you remember, the contract had a recipient who was the creator of the contract, a number of contributors and a array of contributor addresses uh as well as a mapping of um a mapping of uh contributor data. So I've done a little bit of functional

style uh coding to extract the information from the uh from the contributors there. Uh what I did was I Uh I happen to know that the contrib info member of the contract remember that was a mapping in the solidity contract and a mapping is nothing other than a function from its keys to its values and that's how uh mappings are represented in in block apps.js. So I just took this function and I applied it to each member of the contributor's array whose elements are addresses. And that turns the array of addresses into array of of objects containing the contributor information that was put in there when the uh when the contract was invoked.

And after I've obtained all of those things, I join the contracts with the with the function that uh that uses their values. And in this case, it just takes the recipient, the contributor, the number of contributions and the information of all the contributors and prints out a number of lines explaining what exactly was in all of that. And uh well, you can see the results up here. I don't need to go through the uh the the user interface formatting that goes into that. Easily the least interesting part of any program uh writing uh writing writing text to output something. I could give more. Um, turns out that I really like this guy. I'm going to give five more ether. So, uh, I contribute once again.

And now I've given 15. My brother Doug, who makes more money than I do, wants to give 20. He makes more money because he works at a bank for now. Yeah. More money. Soon, I hope I will be the one making more money. Uh so Doug is given 20 and uh so let's close off this uh this little round of crowdsourcing and pay the guy whoever that guy is. So pay the recipient. Uh turns out he raised 35 ether. And what actually happened when I did that is I had a final method in the contract. Let me just sort of uh scroll back up to the

source code so I can point that out to you because it was very small. Payout suicides the contract. It closes it out and pays all the money to the recipient. And way down here, the payout button just invokes the payout function, calls it from the private key, and that function invocation returns a value. uh but in this case it doesn't return anything. So in contract language I just replace the return value with what I want to see which is the balance of the contract and then I format a line that displays it.

as you can see uh this is the same uh basic operation that you witnessed with uh with Kieran's example in Strato but more customized. Strato has your scaffolded page already for you uh with uh with block apps.js, you'll want to write your HTML yourself or if you start with your strat and if you start with your shadow page, you can tweak it a little bit uh and knowing how block apps.js works, you can add more functionality than simply uh than simply showing the storage contents of the address you're working with. Uh block apps.js JS is the uh the power users uh is the power users uh inroads to

connecting Ethereum to the web. Uh anything you can do with solidity you can uh you can benefit from in your application by running this library. So let's go back to this slide and press spacebar again. Uh thank you for for receiving this presentation. Uh we're happy to give this technology to you to enjoy and to uh and to build wonderful wonderful Ethereum apps with.