Using Ethereum with Embark


In the course of interacting with Ethereum, you may find yourself wishing to do more than just exchanging currency.  Smart contracts for every kind of transaction and the privacy and efficiency they provide is poised to become the part of the blockchain movement with the biggest potential impact for world-wide change.  It can be complex, but that is rapidly changing and evolving as well.  

One of the ways to quickly create, test and manage contracts with Ethereum is by using Embark

What is Embark?

Embark is a framework that allows you to easily develop and deploy Decentralized Applications (DApps).

Embark is a fast, easy to use, and powerful developer environment to build and deploy decentralized applications, also known as “DApps”. It integrates with Ethereum blockchains, decentralized storages like IPFSand Swarm, and decentralized communication platforms like Whisper.

Embark’s goal is to make building decentralized applications as easy as possible, by providing all the tools needed and staying extensible at the same time.

Some of Embark’s features, but not all of them, are:

  • Automatic Smart Contract deployment - Embark takes care of deploying your Smart Contracts as well as redeploying them as you make changes to your code.
  • Client development - Build your application with the framework of your choice right within Embark.
  • Testing - Test your applications and Smart Contracts through Web3 in JavaScript
  • Decentralized app distribution - Embark integrates with decentralized storages like IPFS and helps you distribute your app in the network.
  • Peer-to-peer messaging - Send and receive messages via communication protocols like Whisper


Embark has excellent documentation on every phase of the process, here covering everything you'll need to know and more...

General Usage

  • Creating apps
  • Apps structure
  • Running apps
  • Dashboard
  • Environments
  • Configuration

Smart Contracts

  • Configuration
  • Deployment
  • Solidityimpb


Embark Installation


In order to make Embark work on your computer, you need to have some tools installed first. Make sure you have the following ready and in the correct version:

Once done, go ahead and install Embark.

Creating and deploying your first App  Quick start guide.

You can then run and monitor your contracts from Geth or a wallet application like your Mist browser, the same place you can manage your Ethereum wallet account(s).  Once you've launched Mist and connected to your node you can click on the <Contracts> button on the Mist application UI.

A Sample __Hello World__ greeter smart contract

Your first citizen: the Greeter

The Greeter is an intelligent digital entity that lives on the blockchain and is able to have conversations with anyone who interacts with it, based on its input.

Here is its code:

contract Mortal {
    /* Define variable owner of the type address */
    address owner;

    /* This function is executed at initialization and sets the owner of the contract */
    function Mortal() { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() { if (msg.sender == owner) selfdestruct(owner); }

contract Greeter is Mortal {
    /* Define variable greeting of the type string */
    string greeting;

    /* This runs when the contract is executed */
    function Greeter(string _greeting) public {
        greeting = _greeting;

    /* Main function */
    function greet() constant returns (string) {
        return greeting;

You'll notice that there are two different contracts in this code: "mortal" and "greeter". This is because Solidity (the high level contract language we are using) has inheritance, meaning that one contract can inherit characteristics of another. This is very useful to simplify coding as common traits of contracts don't need to be rewritten every time, and all contracts can be written in smaller, more readable chunks. So by just declaring that greeter is mortal you inherited all characteristics from the "mortal" contract and kept the greeter code simple and easy to read.

The inherited characteristic "mortal" simply means that the greeter contract can be killed by its owner, to clean up the blockchain and recover funds locked into it when the contract is no longer needed. Contracts in ethereum are, by default, immortal and have no owner, meaning that once deployed the author has no special privileges anymore. Consider this before deploying.


As of 2018, the most convenient way to develop contracts is using Remix, an online IDE.

To access the compiled code, ensure that the dropdown menu on the right pane has greeter selected. Then click on the Details button directly to the right of the dropdown. In the popup, scroll down and copy all the code in the WEB3DEPLOY textbox.

Create a temporary text file on your computer and paste that code. Make sure to change the first line to look like the following:

var _greeting = "Hello World!"

Now you can paste the resulting text on your geth window, or import the file with loadScript("yourFilename.js"). Wait up to thirty seconds and you'll see a message like this:

Contract mined! address: 0xdaa24d02bad7e9d6a80106db164bad9399a0423e

You may have to "unlock" the account that is sending the transaction using the password you picked in the beginning because you need to pay for the gas costs to deploying your contract: 

Within less than a minute, you should have a log with the contract address, this means you've successfully deployed your contract. You can verify the deployed code (which will be compiled) by using this command:


If it returns anything other than "0x" then congratulations! Your little Greeter is live! If the contract is created again (by performing another eth.sendTransaction), it will be published to a new address.

Run the Greeter

In order to call your bot, just type the following command in your terminal:


Since this call changes nothing on the blockchain, it returns instantly and without any gas cost. You should see it return your greeting:

'Hello World!'




0 out of 0 found this helpful



Please sign in to leave a comment.