In the previous articles we saw all the basics of Ethereum smart contracts development with Solidity. We used Ethereum Wallet and it was great! We were able to have a simple and easy to setup small dev environment. As you figured out it was nice for getting started but what if we want to go deeper? We want to write bigger applications, be able to use multiple source files. Write tests, debug, use a versioning system, deploy multiple contracts at once ect…
To go deeper we’ll use the Embark Framework. Embark Framework is easy to get started with and has a lot of features:
- Automatically deploy contracts and make them available in your JS code. Embark watches for changes, and if you update a contract, Embark will automatically redeploy the contracts (if needed) and the dapp.
- Contracts are available in JS with Promises.
- Keep track of deployed contracts; deploy only when truly needed.
- Manage different chains (e.g testnet, private net, livenet)
- Easily manage complex systems of interdependent contracts.
Decentralized Storage (IPFS)
- Easily Store & Retrieve Data on the DApp through EmbarkJS. Including uploading and retrieving files.
- Deploy the full application to IPFS or Swarm.
Decentralized Communication (Whisper, Orbit)
- Easily send/receive messages through channels in P2P through Whisper or Orbit.
- Integrate with any web technology including React, Foundation, etc..
- Use any build pipeline or tool you wish, including grunt, gulp and webpack.
Installing Embark framework
You can get started on any platform, here are the tools you need:
- Geth: Official Go implementation of Ethereum protocol
Once you got this installed, we’ll use NPM to install the embark framework.
npm -g install embark ethereumjs-testrpc
Embark framework Hello World
The Embark framework contains a basic demo we can deploy to understand how it works. To deploy it type in your terminal the following command, it will create a new folder called embark_demo containing the source code of the demo.
To lunch the demo we’ll need to lunch the simulator. The simulator has two advantages, it will create a blockchain on your computer so your computer will be able to mine when needed to deploy contracts and do other transactions and you don’t have to download all the Ethereum blockchain which will save you space!
Let it run on a terminal window and in a new terminal window you’ll start the Embark demo application with:
On your terminal, the embark dashboard will take life, it should look like this:
Here are the elements:
- The list of your deployed contracts and there addresses, in the Embark demonstration sample, there is only one contract: Simple Storage that have a simple mission: storing one value and make this value readable from outside.
- The services that are currently running. We’ll explain the server running on port 8000 in a minute.
- The logs of what happened
- A console that let’s you interact with your contracts.
So let’s first check the code of the contract that lives in the app/contracts folder of the demo:
In the app folder, you will also notice the css , images and js folders. They contains the sources for building web applications that will interact with the blockchain. Let’s now check what the Embark demo web app does. You’ll need to visit http://localhost:8000/ with your favorite browser.
Note that if you have some apps already using the port 8000, you can change the port used by Embark in the folder config/webserver.json .
So you can see we have a simple interface to interact with our contract, we can set the value stored in the contract, get it and see the calls that were made to interact with it.
The contract calls that were made can also be used in the console we saw in the Embark dashboard.
This was our walk around the Embark framework, in the next lessons we’ll create our own application using the Embark framework.
In the next tutorial we will start developing our first application with Embark Framework and deploy our first contracts.