DApps Framework
Devcon 1 · November 2015 · 9:24
Konstantin Kudryavtsev presents Embark, a dapp development framework built by Iuri Matias. The Devcon 1 talk covers how a framework can automate contract deployment, testing and front end wiring, so developers building on Ethereum spend less time on setup and more on their applications.
Speakers
Topics
From Devcon 1, hosted by Ethereum Foundation.
Transcript
[Music] hello um let's start so my name is Constantine um and I'm presenting umark which is a framework JavaScript framework for um for deps I should get this straight up the way I'm not the author of Embark um the guy who built this is called uras and he lives in Canada and unfortunately he couldn't be here so I'm proing for him today so um I'm afraid he stuck with me um anyway let's let's get to it so
um what is a framework for deps um it's a um framework just like angular or meteor that um supports automate automated contract deployment um Embark specifically supports integration with ipfs with meteor and a couple of other useful tools um it's got tdd support because testing is awesome um it's quite modular and in that sense is um you building pipeline uh build and deploy pipeline agnostic and it's got pretty neat tools for uh multichain management um
why what is it for right um basically so if you try and build your D from scratch and by da them in you know some applications got a bunch of contracts some HTML some JavaScript some CSS and you trying to build some user interface um you kind of um find yourself doing the same things over and over again so let's say have a system of five contracts and you want to change one of them uh as soon as you do that you need to redeploy the contract you need to update your JavaScript references and then if you've got dependencies between different contracts you got to update the references as well and redeploy those contracts and do your JavaScript bindings for those contracts
again so um the point here is that there's certain routines which you inevitably end up doing over and over and over again right and that's clear case for Automation and Embark does just that um so the the quickest and easiest way to get started is to um open up your terminal type and Embark demo uh CD into the um into the app directory and you'll find something um like that so that's your directory structure and Embark uses uh soal COC convention over configuration so you contract files naturally go into
the contracts directory your HTML in the HTML and so on um for testing um soar uses ethereum gsvm which is one of the components of the node ethereum client um as for the JavaScript side of things um as I said it's kind of framework agnostic but by default it's mocka if you're Jasmine user well feel free to use Jasmine um so for chain management you can um you can run your blockchain which is uh basically an integration with gu the go ethereum client um you can specify which environment you want to
use you can do development you can do staging or production um you um has a set of commands for deploying things for running the blockchain for simulating the blockchain um so I'm going to show that in a second um now I'm going to show that now um um so I've already created a demo right uh it's can you see that all right yeah okay so let's fire up our simulator um simulator behaves just like the blockchain it just a little bit faster so
um um is that large is that large enough better all um okay so let's take a look inside our directory so we've got um let's take a look at the contract so by um by default the demo comes with a very simple contract called simple storage it's got a Setter and a getter and basically it on set it sets some story data which is an integer and get well it gets it um it's probably the most simple contract you could think of um so inside the config directory we've
got uh a couple of configs there's a blockchain configuration file which specifies three different environments um development staging production um couple of nice things like RPC hosts and um gas limits and so on um we also got contract uh configuration file which doesn't contain much but um I can tell you this thing is actually quite powerful and um we're going to take a look at some of the features of the contract configuration file in a minute um and we've got our test here um it's very simple test so um we are testing that simple storage is able to set Constructor value and it it can set
the storage value as well uh we can run the test by doing embark and I can say it's deploying the contract it's running the test and right it's still working it's nice um and we can also run the app so testing is all great but what's the point of it app if you can't run it um run go to Local Host 8,000 Yep this is our app
um we can check that the value so it's been initialized with value of 100 we can set that to 10 get again and we get 10 right all let's carry on so um the configuration file that I've mentioned right uh that supports um so one thing it supports is initialization arguments so in this system we've got three different contracts uh user manager my storage and my main contract my main contract needs to be initialized with references to the first three uh first two contracts and we can set that in contracts
tol uh support static banding so let's say we don't want we don't actually want to deploy my the my storage contract we just want to initialize it with we just want to bind it to a specific address on the blockchain that is my storage has been already deployed um and yeah we can we can do that by uh simply providing an address in your in your contracted DMO file um it supports event so let's say on um on deploy of my main contract we want to um make a call to the US user management um user manager contract um well we can do that we can even pass a um um and address to it the address of my main
contract um you can do contract inheritance so um that's yeah that's not a problem you can if your USD and Euro contracts depend on the stable coin contract then um you you all you need to do is to specify that USD and Euro are instance of stable coin um another nice feature of uh Embark is that you can use ipfs so uh by simply installing the ipfs demon and running Embark blockchain and Embark ipfs you um it will nicely package your app and deploy to ipfs and that will be accessible on your Local Host at80 um I probably already mentioned
that supports meteor integration so um just as you would Embark demo you instead ofar instead of typing Embark demo into your command line just type in Embark meteor demo uh it creates very similar app but in meteor and that's it for the demo um