How to create a private Ethereum network

By:  Omar Metwally, MD


  1. To create a private Ethereum network
  2. To deploy a simple contract to your private Ethereum network
  3. To interact with a contract on your private Ethereum network

Target audience:  

Ethereum developers.


The need for this tutorial arises from outdated Ethereum documentation, resulting in hair-pulling, heartburn, and insomnia.


Isolate your development environment, and your private Ethereum network, from any real Ether you might have. It’s easy to compromise your machine and lose real money if you slip up.

Step 1: Set up a virtual server and install Ethereum command-line tools

Many tutorials guide you through deploying contracts using the Ethereum wallet GUI. I’m using the Go Ethereum client (geth) and encourage others to learn how to use the command line interface (CLI). The better you understand the Ethereum client’s internal workings and the anatomy of a blockchain, the more power to you. It doesn’t matter which hosting service you use,  but these instructions assume you’re running an Ubuntu server. [Geth Installation instructions for Ubuntu] 

My private network is called “UCSFnet” at this (fake) IP address

Very important: make sure you set aside at least 2GB RAM on your virtual server in order for mining to work. If you skimp on RAM, mining may not work.

Now open a new terminal window, log into your Ubuntu server via SSH and create your working directory called “ucsfnet”

ssh root@
mkdir ucsfnet
cd ucsfnet
mkdir data
mkdir source

Step 2: Create genesis block

The genesis block is the first block of any blockchain and its parameters are specified in “genesis.json”, which I saved under /root/ucsfnet/genesis.json. My genesis block looks something like this:

"config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0

  "alloc"      : {
  "0x0000000000000000000000000000000000000001": {"balance": "111111111"},
  "0x0000000000000000000000000000000000000002": {"balance": "222222222"}

  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x00001",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000107",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"

Note that chainId=1 refers to the main Ethereum network, so it’s important to create a unique chainId for your network so your client doesn’t confuse your private blockchain with the main network. For the sake of illustration and testing, set mining difficulty to a low value. Also make sure you specify a unique nonce to start out with. The alloc field allows you to pre-populate accounts with Ether.

Now navigate to the directory where you created your genesis.json file and initialize the bootnode, a node through which your Ethereum client can join your private network and interact with other nodes connected to your private network.

cd /root/ucsfnet/data
geth --datadir=/root/ucsfnet/data init /root/ucsfnet/genesis.json
bootnode --genkey=boot.key
bootnode --nodekey=boot.key

Pay attention to the enode address that the previous commands results. You’ll need this for the next step.

Step 3: Connect to your externally reachable bootnode

The bootnode you created in the previous step is externally reachable, and in this step we’re going to connect to that node to create a one-node network. As you go through this tutorial and expand your knowledge of Ethereum networking, you’ll be able to add infinitely many nodes to your private network. The following commands create the geth.ipc file you’ll need to interact with your network in the subsequent steps. However after completing this tutorial, you’ll be able to skip this step the next time you connect to your network if you’re developing/testing and not using any networking protocols.

Open a new terminal window:

ssh root@

geth --datadir=/root/ucsfnet/data --bootnodes=enode://148f3....@

Replace 148f3…. above with the enode address from Step 2. Make sure to include the enode://  prefix.

Step 4: Create a new account and check your balance

Start by opening a new terminal window and connecting to your virtual server via SSH:

ssh root@
geth attach /root/ucsfnet/data/geth.ipc 
> eth.accounts

You’ll notice that there are no account addresses yet. Now you’ll create your first account. Be sure to replace “mypassword” with a strong password. Remember it and keep it safe; Ethereum is unforgiving in that there is no way to unlock your account if you forget your password!

> personal.newAccount("mypassword")
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")

Remember your account’s address, which is prefixed by “0x”. Notice that your account has zero Ether, but don’t be discouraged. I’ll soon turn you into an Ethereum billionaire (but alas, the Ether you collect on your private network is only good on your private network).

Step 5: Mine on your private network

The purpose of mining here is two-fold. First you create Ether which you’ll need to power your transaction through gas (an Ethereum sub-unit). Second, mining incorporates your transactions into the blockchain. Open a new terminal window and connect to your private server:

ssh root@
geth --datadir=/root/ucsfnet/data --mine --minerthreads=1 --etherbase=0x...

The etherbase parameter specifies the address which should receive the Ether you generate by mining. This should contain your wallet address from Step 4. If you check your account balance again (Step 4), you’ll find that you quickly became a billionaire. Congratulations! Again, the Ether you generate on your private network is only good on your private network, but that’s OK. Your newfound knowledge of how to develop for Ethereum is more valuable than all the Ether in the world.

Step 6: Compile a simple contract

Unfortunately, the official Ethereum documentation has not been updated to reflect the fact that compiling using the solC compiler is no longer possible via RPC. This means that you will end up in a rabbit hole if you try to follow the instructions on the official Ethereum documentation and many other tutorials based on official documentation. There are 2 ways to compile contracts, and I encourage you do try both so you understand what’s going on under the hood.

First install the command-line compiler, solC:

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

Now open a new terminal window, connect to your server via SSH, and navigate to the directory where your source code will live:

cd /root/ucsfnet/source

And save this demo “greeter” contract in /root/ucsfnet/greeter.sol:

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 = "Hello, World!";

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

Now compile this contract using solC:

solc --bin --abi  -o /root/ucsfnet/source /root/ucsfnet/source/greeter.sol 

In the above command, the bin and abi flags tell the solC compiler to generate Ethereum Virtual Machine (EVM) bytecode and an Application Binary Inferface (ABI) file, respectively. The o flag defines an output directory where these files will be created, and the last argument is the location of the contract (*.sol file) you want to compile.

Compiling a contract this way generates two files:

EVM file, indicated by the *.bin extension. This corresponds to the contract bytecode generated by the web-based compiler, which is easier to use and will be described below.

ABI file, indicated by an *.abi extension. An application binary interface is like an outline or template of your contract and helps you and others interact with the contract when it’s live on the blockchain.

Open both files using vim or your text editor of choice to see what they contain. Understanding what these files contain will make deploying and interacting with your contracts much clearer.

Alternatively, you can use the online compiler. This is easier because you can just copy-paste your Solidity code. However both methods are equivalent, and I’ll elaborate on this below. Copy and paste the code in greeter.sol (above) into the online compiler. Give it a second, and then click on the “Contract details…” link. Notice that the contents of the Bytecode field are equivalent to the greeter.bin file that you created using solC. Also notice that the Interface field is equivalent to the contents of the greeter.abi file you created when you compiled using the command-line solC compiler.

Step 7: Deploy a “Greeter” contract to your private network

Copy the contents of the Web3 deploy field in the online compiler. Paste them into a text editor on your computer and note the bolded changes I made:

var _greeting = 'UCSFnet lives!';

var browser_ballot_sol_greeterContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"type":"constructor"}]);

var browser_ballot_sol_greeter =



    from: web3.eth.accounts[0],

    data: '0x6060604052341561000f57600080fd5b6040516103dd3803806103dd833981016040528080518201919050505b5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b6040805190810160405280600d81526020017f48656c6c6f2c20576f726c642100000000000000000000000000000000000000815250600190805190602001906100b99291906100c1565b505b50610166565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061010257805160ff1916838001178555610130565b82800160010185558215610130579182015b8281111561012f578251825591602001919060010190610114565b5b50905061013d9190610141565b5090565b61016391905b8082111561015f576000816000905550600101610147565b5090565b90565b610268806101756000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610049578063cfae32171461005e575b600080fd5b341561005457600080fd5b61005c6100ed565b005b341561006957600080fd5b61007161017f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b25780820151818401525b602081019050610096565b50505050905090810190601f1680156100df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561017c576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b610187610228565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561021d5780601f106101f25761010080835404028352916020019161021d565b820191906000526020600020905b81548152906001019060200180831161020057829003601f168201915b505050505090505b90565b6020604051908101604052806000815250905600a165627a7a7230582069d50e4318daa30d3f74bb817c3b0cb732c4ec6a493eb108266c548906c8b6d70029',

    gas: '1000000'

  }, function (e, contract){

   console.log(e, contract);

   if (typeof contract.address !== 'undefined') {

        console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);



Save the above as myContract.js.

Before we proceed, make sure your account balance is non-zero and that your account is unlocked. If your balance is too low, or if your account is locked, you won’t be able to deploy your contract. Follow the above steps to make sure you generate Ether by mining, and unlock your account as follows (replacing mypassword with the password you invented while creating your account):

Open new terminal window:

ssh root@ 
geth attach /root/ucsfnet/data/geth.ipc 
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
> personal.unlockAccount(eth.accounts[0], "mypassword")

If I’ve lost you, pay attention here because this is important. This is where the Ethereum documentation hasn’t been updated yet, creating confusion regarding how contracts are compiled. Note that the web3.eth.contract() function takes as an argument an ABI. This is the same as the greeter.abi file you created using the solC compiler! Also note that the data field is equivalent to the greeter.bin EVM bytecode, with the exception that it’s prefixed by “0x”. 

Time to deploy your contract:


You should see something like:

Contract mined! address: 0x4000737c8bd7bbe3dee190b6342ba1245f5452d1 transactionHash: 0x0a4c798467f9b40f2c4ec766657d0ec07c324659ea76fcc9c8ad28fc0a192319

Congratulations! Your contract lives at the following address on your private blockchain:


Make a note of this. You’ll need your contract’s address to interact with it (and allow others to do the same).

If this didn’t work, make sure you’re actively mining in another window so that your transaction is incorporated into the blockchain.

Step 8: Interacting with a contract

Again, this is another place where the Ethereum documentation hasn’t yet been updated and refers to deprecated functions. With your geth client fired up, try the following:

> var abi = '[{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"type":"constructor"}]'
> var abi = JSON.parse(abi)
> var contract = web3.eth.contract(abi)
> var c ="0x4000737c8bd7bbe3dee190b6342ba1245f5452d1")
> c.greet()

The first 3 inputs above define what the contract looks like via its ABI. The method takes as an argument the address where your contract lives.

You should see the following output:

UCSFnet lives! 

Big caveat: geth chokes if any of your inputs contain illegal characters. Id est:

“ (illegal) is not equal to  " (legal) 


‘ (illegal) is not equal to ' (legal) 


We covered a lot of ground here, from setting up your own Ethereum network to compiling your contract (and avoiding rabbit holes created by outdated documentation) to deploying the contract and interacting with it. Whew! If you ever get stuck and need to start over, just reboot your server and delete your blockchain (understanding the implications of what this means…):

rm -R /root/ucsfnet/data/geth/chaindata

“Wir werden von so manchen Despoten – etwa Institutionen, Überzeugungen oder auch Neurosen – beherrscht, die wir aus dem Weg räumen können, wenn wir sie analysieren und verstehen.”

We are ruled by so many despots — institutions, convictions, and neuroses — which we can clear away, if we analyze and understand them

— Isaiah Berlin

Portland smoke

Support my research!

If you find this information helpful, please consider supporting my research by donating Ether or Bitcoin. Equitable, transparent, high-quality healthcare for all!

ETH donations:  0x1b4Ba9c1811233805dC4f12Ca32F22cfD85DB212

BTC donations:  1Ef7oYi1zVpA4bw7hUcD8841wbdtCw4Xen

Suggested reading:

  • Nice low-level description of networking in Ethereum (uses the Python-based client): 

  • Setting up private network or local cluster

  • Connecting to the network

  • The Go Ethereum client

  • Official Ethereum command line tool documentation

Learn Ethereum the hard way

Clear Paper


Note: In the spirit of open collaboration, I’m  keeping a public lab notebook of my work as a Clinical Informatics Fella at UCSF. Whether you cite or steal this, remember to build cool things that help people live healthier lives.


Educational objectives

There are a number of excellent technically focused blog posts on Ethereum out there. If you are interested in building Ethereum applications, I recommend making your way through these technical references (see end of article). This article is intended for non-technical readers interested in understanding, on a high level, the real-world implications of Ethereum’s application paradigm. More specifically, you should be able to answer these questions after reading this article:

  • What is Ethereum and how does it work?
  • Should I use Ethereum for my project?
  • What are the pros & cons of Ethereum?


Welcome to Hell

Let’s pretend you have a crazy boss (let’s call her Mary) who’s set on making your life difficult. You and Mary meet every month to check in and make sure you’re both on track. Mary takes out her notebook and takes notes while you share with her what’s going well and what’s not going as well. Because you’re an honest (and somewhat naive) person who hasn’t yet encountered someone like Mary, you start using these meetings as opportunities to speak openly, give and receive feedback, finding comfort in the fact that Mary’s faithfully keeping a record — a ledger — of your conversations. A month passes, and then two months, and Mary’s insanity pervades the workplace. With each subsequent meeting with Mary, she seems to glare at you with wider crazy-eyes, clench her teeth until they sound like they’re about to crack, and stabs her pen ever harder into her notebook while she keeps records of your discussions.

Three months into your job, you’re fed up with her madness and decide to resign (fortunately, you’re not a medical resident or other indentured servant and have the freedom to do so). Mary leads you to a quiet corner, throws a death stare at you, and growls: “If you resign, I will personally make sure you never find a job ever again.” By this point, the stench of bodies in Mary’s closet is overwhelming, and you email Mary to give 30-day notice. Then all hell breaks loose.

In following month, Mary copies you on several emails to her bosses. One of the emails accuses you of harassing her assistant (whom you’ve never interacted with). Another email warns you of several missed deadlines (for projects which never existed). Some emails state that no one has been able to reach you by email or phone (you’ve answered every call and email in the most timely fashion). You’re neither the first nor last of Mary’s victims, and you quickly learn that she’s more than a psychopath, she’s also written the book on psychological manipulation, deception, and torture. She’s creating a fictitious paper trail by sending contrived emails and writing a book of alternative facts, which her complicit assistant is co-authoring.

How can you shed light on Mary’s evil tactics and show others that her ledger is as legitimate as an acid trip? Because you’re a clever hacker, you decide to use Ethereum to shed light on a rancid situation.



A Distributed Ledger 

Pretend the Ethereum “blockchain” is a magic notebook that serves as a ledger. This notebook can appear in anyone’s hands, and every copy of this notebook is identical. This magic notebook is so smart it can understand your commands and write on its own pages. When one of its pages is written on, the other notebooks vote whether to accept the new page. If they do accept the new page, this change is reflected in every magic notebook. These magic notebooks follow you into meetings with Mary and record their own version of “the truth.” Each page in this notebook is analogous to a “block” in a “blockchain.”

So you buy yourself a magic notebook and bring it to your next meeting with Mary. As usual, she’s preparing her own notebook of alternative facts.  Her assistant, Karen, also shows up to the meeting with her own notebook of alternatively alternative facts. So there you are, in Mary’s office with Mary and Karen, everyone clutching their notebooks.

You:  "I quit."  (magic notebook hears this and writes it on page 1)

Mary:  "Good riddance." (magic notebook hears this and writes it on page 2)

You:  "Before I leave, you still owe me a paycheck." (magic notebook hears this and writes it on page 3)

Karen:  "You picked up the paycheck last week. We owe you nothing." (magic notebook hears this and writes it on page 4)

You:  "No you didn't. I've been asking you for that paycheck for weeks."(magic notebook hears this and writes it on page 5)

Realizing this is going no where, you walk out of Mary’s office carrying your magic notebook.

You next see Mary and Karen in court: you’re suing them for unpaid wages, and you bring along your magic notebook to set the facts right. When the judge asks you when you announced that you’re quitting, your magic notebook recites what’s written on page one: your statement (“I quit”) along with a timestamp. Mary and Karen jump to their feet and hold up copies of their own notebooks. However, the judge did her research on this new magic notebook, which is reputed to be the best ledger in the history of mankind because it doesn’t rest in any one person’s or organization’s hands. The truth doesn’t rest in Mary or Karen’s notebooks or email inboxes (or in either of their minds); the truth — the Ethereum ledger — is the account provided by the magic notebook, which is in everyone’s hands and is guaranteed to contain the same text on every page .

It’s worth repeating emphatically here that the Ethereum blockchain is a distributed ledger. 

Realizing the signifiance of this jargon-laden statement, you decide to go further than just shedding light on Mary’s career of lies and deception. You’re going to make Mary pay for all of the people she’s abused and manipulated over the years, and you’re going to do it with Ethereum. As you study this article and read more about how Ethereum works, you realize that the magic notebook is more than just a record of events. The notebook can execute logic (in the form of “contracts”) and store/modify/delete data. This is one big difference between Bitcoin and Ethereum. A Turing-complete system, such as Ethereum, can execute logic; unlike Bitcoin, the Ethereum Virtual Machine (EVM) is a stack machine. You can write contracts that transfer money and include basic logic to allow others to interact with your contract in a transparent manner. Anyone interested in examining a contract can do so.

If you had heard of Ethereum before you started working for Mary, you could have written a contract that states something like:








Unlike a traditional contract, Ethereum contracts:

  • are transparent and can be examined by anyone
  • are trustless, meaning they execute faithfully and automatically
  • do not need lawyers or courts for interpretation

As your knowledge of Ethereum grows, you realize that you would have been better off writing your employment contract on the Ethereum blockchain rather than relying on Mary and her team of corporate attorneys. Had your contract been written on the Ethereum blockchain, you wouldn’t have had to rely on Mary’s sanity or lack thereof to get paid. The codified contract would execute autonomously, can be reviewed by you or anyone else, and does not need middlewomen/middlemen to interpret or execute (Auf Wiedersehen lawyers, HR staff, administrators, etc). In case Mary was still delusional enough to argue with the Ethereum ledger, the magic notebook would quickly provide proof of payment (or lack thereof) and the conditions under which the logic was executed. The logic on the Ethereum blockchain is transparent.

The current paradigm of hosting applications on a private server is analogous to doing business with Mary and Karen. The logic is centralized and opaque. I trust most applications about as much as I trust Mary and Karen. The average application is hosted on one or a cluster of privately owned and operated servers, and most applications are not open source (and even if they are open source, the average user doesn’t have the means to perform checksums and make sure they’re running the code they think they are). If the server crashes or the application behaves in unexpected ways, well, hard luck fella. Why would anyone trust the software equivalent of Mary & Karen when they could trust a decentralized ledger running autonomously executing logic?

Without getting too bogged down in details, I include this simple example of an Ethereum contract that creates a simple voting mechanism.

pragma solidity ^0.4.0;
contract Ballot {

struct Voter {
 uint weight;
 bool voted;
 uint8 vote;
 address delegate;
 struct Proposal {
 uint voteCount;

address chairperson;
 mapping(address => Voter) voters;
 Proposal[] proposals;

/// Create a new ballot with $(_numProposals) different proposals.
 function Ballot(uint8 _numProposals) {
 chairperson = msg.sender;
 voters[chairperson].weight = 1;
 proposals.length = _numProposals;

/// Give $(voter) the right to vote on this ballot.
 /// May only be called by $(chairperson).
 function giveRightToVote(address voter) {
 if (msg.sender != chairperson || voters[voter].voted) return;
 voters[voter].weight = 1;

/// Delegate your vote to the voter $(to).
 function delegate(address to) {
 Voter sender = voters[msg.sender]; // assigns reference
 if (sender.voted) return;
 while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
 to = voters[to].delegate;
 if (to == msg.sender) return;
 sender.voted = true;
 sender.delegate = to;
 Voter delegate = voters[to];
 if (delegate.voted)
 proposals[].voteCount += sender.weight;
 delegate.weight += sender.weight;

/// Give a single vote to proposal $(proposal).
 function vote(uint8 proposal) {
 Voter sender = voters[msg.sender];
 if (sender.voted || proposal >= proposals.length) return;
 sender.voted = true; = proposal;
 proposals[proposal].voteCount += sender.weight;

function winningProposal() constant returns (uint8 winningProposal) {
 uint256 winningVoteCount = 0;
 for (uint8 proposal = 0; proposal < proposals.length; proposal++)
 if (proposals[proposal].voteCount > winningVoteCount) {
 winningVoteCount = proposals[proposal].voteCount;
 winningProposal = proposal;


Why develop on Ethereum?

Now that you know how Ethereum works, you have the luxury of living to witness one of the most interesting, exciting, and important developments in computing, and you too can design and develop applications on the Ethereum blockchain. Why not write an employment contract on the Ethereum blockchain that gives you and your peers a democratic way of removing problematic elements in the workplace? Or an employment contract that distributes an organizations profits more equitably and transparently? But before you can decide whether it makes sense to ditch a virtual server running your standard Python/Ruby/NodeJS/PHP/[fill in the blank] stack in favor of Ethereum, you should note a few more pros and cons of Ethereum:

Unlike the Bitcoin protocol, which is a distributed ledger of transactions based on monetary (Bitcoin) inputs and unspent transactional outputs, Ethereum is account-based. This is getting into technical details that may not interest the intended audience of this post, but it should be noted that in Ethereum there are account addresses identify users as well as individual contracts written to the Ethereum blockchain. Like Bitcoin, the Ethereum protocol is based on a cryptocurrency called Ether, which is used to fund all transactions on the Ethereum blockchain (more on this below). And just like an address that you can use to send and receive Bitcoin and Ether payments, your Ethereum contracts also have addresses which function as handles to allow users to interact with your code and identify it on the Ethereum blockchain.


Basic anatomy of an Ethereum contract

An Ethereum contract consists of the code you write and the state of the contract (i.e. the data associated with the contract). As described in the Solidity documentation, the magic happens in between the curly brackets, the body of a contract:

contract requestFile {

    // stuff happens here ...


The “stuff” consists of state variables, functions, function modifiers, and events, which will look familiar to you if you’re fluent in one of many programming languages that use these paradigms.

State variables are permanently stored in contract storage and include types such as integers (int and uint), booleans (bool), addresses (address, address.balance, address.transfer), fixed and dynamically-sized byte arrays (bytes, string), string literals, enums, structs, and mappings (similar, but not identical to, hash tables). The EVM uses standard logical operators, including comparison operators, bit operators, and index access. See the reference above for more details.

How large is a contract storage area? Vitalik Buterin answers this here. Bottom line: 2^261 bytes. That means that you’ll never really be limited by size, but rather, by the cost of conducting transactions on the Ethereum blockchain (see “Economics of Ethereum contracts” below).

Functions work similarly to other programming languages and take the form of:

function audit() returns (address addr) {
    // stuff happens here...

As described in the Solidity documentation, functions can be called internally or externally and have different levels of visibility, like in programming languages such as C++, Java and Python.

Function modifiers “amend the semantics of functions in a declarative way.” I’ll skip the technical details here.

Events are basically functions that use the EVM’s logging mechanism. If you’ve developed Android apps, you’ve probably used something similar.

If you’re itching to deploy a real contract to the Ethereum blockchain, check out my earlier tutorial.


Economics of Ethereum contracts

On a macro scale, Ethereum is a giant computer powered by every machine running the full Ethereum client. Just like every step and breath we take costs energy, so too does every computation performed by your computer require a finite amount of electrical energy. The Ethereum network is no different. The energy required to keep adding blocks to the blockchain, transfer Ether, and execute contracts is provided in the form of “gas” (an Ethereum subunit). Unlike a local machine such as your laptop, and unlike a virtual server (which runs on a real machine too), Ethereum contracts are interpreted by the Ethereum Virtual Machine, the stack machine that converts Solidity code into instructions to interact with the Ethereum blockchain.  Unlike the Bitcoin protocol, in which each transaction has a predictable cost to the network, the cost of transactions on the Ethereum blockchain depends on bandwidth consumed, computational power, and the size of data that’s being manipulated. Each transaction specifies how much gas it is willing to consume and a gas price. In the event of unused gas, the sender receives gas_rem * gas_price, and the miner of the block receives a reward of (startgas-gas_rem) * gas_price. Id est, there is a cost of conduction transactions, and miners, are rewarded financially for using their own computational power to create new blocks on the blockchain and keep the ledger going.

The economics of current application development profoundly shape how software is developed and used. Many consumer-facing applications are available for a cost on app stores or can be downloaded for a fee; many other consumer-facing applications are supported by adverts, in-app purchases, and subscription fees. Ethereum’s transactional economics were designed to safeguard against malicious agents, and understanding the Ethereum blockchain economy is important to understanding how applications on the Ethereum blockchain will function. This is illustrated in the “Security considerations” section below.

There are some good websites with details on Ethereum economics, including Ethereum’s Design Rationale and Ethereum Gas Economics.


Security considerations

What better way to learn good security practices on the Ethereum blockchain than to confront the most malicious of actors, your former wicked boss? While you’ve been writing Ethereum applications, Mary learned a thing or two about this Ether thingy and wrote their own contract to hinder the Ethereum network and suck your account dry of Ether. Let’s say that Mary tricks her next hapless victim into executing an Ethereum contract that does the following:

contract youGotPunked {

    function newEmployee(address dest, uint employeeId) {
        while(true) { };

Mary is tricking her next batch of employees who aren’t savvy enough to study the contract into calling an infinite loop. If you’ve ever written an infinite loop on your machine, you know you can hang your machine by wasting all of your machine’s computing resources on executing a loop that does nothing forever. Mary’s new employees call the contract, which then runs forever, wasting computing resources across the Ethereum network. Because each transaction (such as calling the above contract) costs gas, Mary can’t use this old trick to lock up the Ethereum network.

Mary goes back to the drawing board and comes up with another contract (this example is also provided in the Solidity documentation):

contract TxAttackWallet {
    address owner;

    function TxAttackWallet() {
        owner = msg.sender;

    function() {
        TxUserWallet(msg.sender).transferTo(owner, msg.sender.balance);

When Mary’s hapless new employees call this contract, it empties all of their funds (msg.sender.balance) into Mary’s account (address owner). People have used their understanding of Ethereum’s blockchain and simple tactics such as this account emptying trick to transfer hundreds of millions of dollars worth of Ether in unexpected ways. Bottom line: there is no such thing as a perfectly secure system. The amount of energy expended in securing a system should be proportional to what’s at stake. Ethereum is no more or less inherently secure than Google or Microsoft’s applications.


Ethereum in healthcare 

I’m drawn to an Ethereum-based electronic health record for the same reasons I wouldn’t want anything to do with Mary and Karen. The next generation of EHRs on a blockchain should:

  • be secure, with fail-proof access control
  • be infallible, with mechanisms to deter malicious attacks on the network
  • be distributed, so that patients, providers, and researchers can benefit from responsible use data
  • be distributed, so that inter-operability is a given
  • be distributed, so that data is never lost (while preserving consensus)
  • be transparent, so that there’s an audit trail of who is accessing what
  • be transparent, so that there’s an audit trail of all transactions on the blockchain
  • be transparent, allowing health services to be rendered in the most cost-effective way possible
  • be autonomous, allowing health services to be rendered without costly third-parties who currently monopolize health data


Now enough White, Yellow, Mauve and Clear Papers. Let’s see some code!



“It’s only work if you’d rather be doing something else” (JM Barrie). I couldn’t think of a better way to spend my time, thanks to this opportunity to be a Clinical Informatics Fella at UCSF Medical Center. I’m grateful to UCSF’s Department of Hospital Medicine, my mentor, Dr. David Avrin, and my colleagues Dr. Michael Wang and Dr. Steven Chen, for their support and feedback.










Comments on the California Department of Public Health’s proposed regulations on medical cannabis

Note: The opinions I express here should not be construed as medical or legal advice. Marijuana is classified by the federal government as a Schedule I drug. Protect your freedom and your health by consulting a lawyer and your doctor for legal and medical advice.

In response to the California Department of Public Health’s invitation to comment on proposed regulations on medical cannabis:

I welcome the State of California’s proposed regulations for the manufacturing of medical cannabis, which I believe will help protect the safety of individual consumers and communities. I offer here my opinions on these proposals.

Despite its federal status as a Schedule I drug, cannabis is used medicinally by millions of Americans. Although only a small handful of compounds produced by plants in the Cannabis genus have been characterized, this number continues to grow as evolving legislation opens doors to medical and scientific research. Many of these compounds are known to possess therapeutic potential, individually or in synergy with other compounds. In the absence of a comprehensive body of scientific literature on C. sativa and C. indica, patients and recommending providers have few tools to help them tailor cannabis-based therapeutics, largely relying on empiric observations and trial-and-error. Each strain has a unique portfolio of psychoactive and non-psychoactive compounds which affect individuals uniquely.

Safeguarding health consumers’ safety should be the primary goal of these proposed regulations. Protecting communities and preserving the environment are also of paramount importance. The proposed regulations offer many theoretical benefits. My critique stems from a concern that these regulations, whether intentionally or unintentionally, place the interests of larger growers over smaller growers. I fear the rise of the cannabis industry’s equivalent of “Big Tobacco.” The proposed regulations disproportionately burden smaller growers with financial and bureaucratic hurdles which I worry will render so-called “Cottage” operations non-viable. The proposed regulations would impose a higher fee-to-revenue ratio for “Cultivation Licenses” for Tier 1 operations, defined as those yielding less than $100,000 in annual revenues, compared to higher tier operations.

For instance, Section 8305 and Section 8313 (“Cannabis waste management”) do not discriminate between small and very small growers, and large operations which pose much greater threats to the environment and water supply.

Favoring larger growers over smaller growers poses a threat to medical cannabis’ genetic diversity by incentivizing growers to produce the most profitable strains, rather than supplying the market with a variety of strains to meet the diverse needs of patients. This is the case with conventional as well as organic produce.

I urge the State of California to consider creating a separate category for “micro-entities,” which I define here for the sake of argument as growers possessing no more than 6 plants. Regulations should also discriminate between micro-entities who manufacture medical cannabis for their personal consumption, and micro-entities who sell what they produce. The current definition of “commercial cannabis activity” as activities that include “cultivation, possession, manufacture, processing, storing, laboratory testing, labeling, transporting, distribution, or sale of medical cannabis or a medical cannabis product” is problematic because it does not make the aforementioned distinction. The rationale for imposing regulations on large growers to protect consumers, communities, and the environment does not apply equally to large and small growers. Micro-entities should be subject to regulations that do not disproportionately burden them and should be exempt from much of the administratively burdensome language of these proposals. Because micro-entities do not share the same financial incentives as large growers, I hope that making it easier for micro-entities to manufacture medical cannabis would promote the genetic diversity of medical cannabis.

I would also like to briefly comment on the language of a few other statements which caught my attention. Section 8401 describes a “Track-and-Trace” system that would allow the State of California to account for the production and dissemination of medical cannabis products. We should apply our experience with other industries to prevent State and private monopolies from hindering innovation. I use the example of Electronic Health Records because of my familiarity with the healthcare industry: stringent regulation on electronic medical record vendors has promoted the formation of monopolies to the detriment of innovators who would have otherwise worked to develop more functional and less expensive software. It is crucial that a State-sponsored Track-and-Trace system feature an open API which would facilitate the growth of an ecosystem of tools to help growers and manufacturers comply with these regulations.

I also advocate against a separate “Nursery License”, particularly for smaller growers, because it would impose further licensing hurdles for these growers.

Article 1, Section 8000, Subsection (f) states: “Commingling is prohibited in Section 8207 of these proposed regulations to retain the integrity and clear accountability of the product.” I strongly agree with this statement for the aforementioned reasons.

Subsection (t) defines “outdoor cultivation” as “a method of cultivation techniques that does not use light deprivation techniques. Outdoor growers who rely entirely on natural sunlight can utilize light deprivation to harvest up to 4 times annually. I find the definition of outdoor cultivation inaccurate and misleading. Outdoor cultivation could instead be defined by whether or not electrical energy is the primary light source for marijuana plants.

My final comments pertain to county regulations rather than state regulations, but I would like to express them here since state regulations supersede county regulations. Mendocino County imposes regulations on marijuana farms which also apply to vineyards, such as having restrooms in greenhouses, limits to the maximum incline grade leading to a greenhouse, and the construction of greenhouses. Again, safety of patients, cannabis industry workers, communities, and the environment is paramount. At the same time, It’s worth bearing in mind that the nature of a medical marijuana farm is much different than a vineyard. To consumers of medical cannabis, marijuana is medication. A vineyard is a recreational area and its product has no therapeutic indication accepted by the medical community. I again urge the writers of these regulations and California voters to consider a more nuanced definition of “commercial cannabis activity” than the current one.

Thank you for the opportunity to comment on these proposed medical cannabis manufacturing regulations.


Omar Metwally, MD


Healthcare on the Ethereum Blockchain

Since Ethereum’s conception, I’ve dreamed of a blockchain-based healthcare services economy and presented the idea at BitTorrent’s headquarters 3 years ago. It’s also taken me that long to conceive of a concrete study of this protocol’s readiness for the limelight. With Ethereum’s adoption by a number of blue chip companies, including JP Morgan and Microsoft, its inevitability is clear. While still unreachably abstract to many people, I believe that healthcare’s state of disarray is a perfect environment to test the waters. As I get ready to start a Clinical Informatics fellowship at UCSF Medical Center, I’m prototyping such a blockchain-based health services marketplace and would like to humbly present the proposal to the Ethereum community for its feedback.

Pricing for healthcare services is currently based on prices determined by insurance companies’ ability to negotiate price points with groups of healthcare providers, individual providers, and healthcare systems. The lack of a true free market, and insurance companies’ administrative overhead, contribute to inflated prices for healthcare services across the board. [Figure 1: Health services marketplace in the blockchain era]


Figure 1: Health services marketplace in the blockchain era. Red text indicates how things work presently. Green indicates how things might work in a health services economy founded on the Ethereum blockchain. Notice the absence of insurance companies in the latter, hypothetical scenario. Their role has yet to be determined. I use laboratory testing as an example, but this would apply to imaging studies, office visits, surgical procedures, and consultations.


Enter Ethereum, a next-generation blockchain protocol for automatically executing “smart contracts.” Autonomously executed contracts obviate the need for escrow, attorneys, and administrators. Like Bitcoin’s protocol, Ethereum is a distributed blockchain that is open source, not owned by anyone, and runs off any and all computers running the client software. Ethereum’s novelty – and power – lies in the fact that it’s a Turing-complete system. Ethereum, unlike Bitcoin has mechanisms for executing logic, so smart contracts can be written by anyone, hosted on the Ethereum blockchain, and anyone in the world can interact with these contracts with the endpoint of manipulating data and moving money in the form of Ether (also a cryptocurrency).

So why not harness the Ethereum protocol to create a distributed, open source healthcare marketplace? Without administrative overhead (which accounts for the majority of an insurance company’s expenses, which are then passed on to patients and healthcare systems) and with the freedom for any provider of healthcare services to bid for a service (imaging, lab testing, consultations, procedures…), I hypothesize that the cost of healthcare services will be reduced to approximately 10% of its current artificially inflated price. Further contributing to cost and redundancy of healthcare expenditures is data siloing, the isolation of data on servers without APIs to set them free. Many healthcare providers will agree that it’s often much easier to repeat an expensive study than obtain records of that same procedure performed at an outside hospital (even if the study was just performed hours or days ago, and oftentimes, even if the study was performed at an affiliated hospital!). Ethereum’s distributed blockchain is a global ledger of everyone’s health information. I predict that sound security protocols, which need to be developed with healthcare’s unique needs in mind, will necessitate the use of biometric data to associate data on the blockchain with individuals.

So, how can we test the former hypothesis, that Ethereum can reduce the cost of healthcare services to 10% of their current prices?

I propose simulating such a bidding system to start collecting data on the free market prices Ethereum will foster by surveying physicians based in the community, as well as groups contracting with academic medical centers. If I survey Dr. Roentgen, Dr. Tomo, and Dr. Houndsfield (and a few hundred other radiologists) asking them if they would accept $X cash payment for imaging study A, B, or C (e.g. chest x-ray, mammogram, brain MRI…) performed STAT, tomorrow, or next month, we will start to approach theoretical market price for these studies.

If you are a fellow Ethereum developer or are otherwise interested in collaborating in the spirit of establishing healthcare as a human right on the Ethereum blockchain, please send me a line! I’m dreaming up experiments and am seeking partners in code.

Portland smoke

[Daydreaming in Portland]

Omar Metwally, MD

Sunday April 30th, 2017

Portland, Oregon


Letter to my Family on Christmas Eve

Dear Father and Mother,

I can imagine how cozy it must be now in Michigan, and I wish I could have shared the season with you. I had a beautiful day starting with yoga, then a trip to the farmer’s market, where I had a half-hour conversation with a farmer famous for growing the best pomegranates ever. I bought his last 15 pomegranates; he was retiring and moving to a gorgeous country estate in Montana. He had made his wealth in business then started farming as a hobby, and made a killing doing that too! He was the wisest person I’ve ever met. He said that he has everything because he has his health.

I got sunburned on the way back with my moonroof down. I’m as white as mom.

When I got home, I started chatting with my neighbor for the first time, and he invited me into his place to meet his wife and 2 children — such a beautiful family, a Nepalese couple and their 2 kids. I gave them some pomegranates, and they fed me dinner. It was delicious.

And tonight I’m working the 10pm to 10am shift at the hospital. I couldn’t think of a better way to spend Christmas Eve, taking care of people. It was a day of adventures. I think I live the happiest and most interesting life.

I told them I was vegetarian (something I’ve recently started), and he looked so disappointed. He was like, I know about your religion. I joked that my religion is yoga, and he continued, I know about halal and I don’t eat pork either. It turns out we both make our own yoghurt, too! So I said what the heck, if it came from your hands it must be delicious. It was chicken, tofu and vegetables cooked in a spicy broth with curry. It was heavenly.

I ate every last piece of ricepom

Your Very Affectionate Son,


For the love of tobacco

Three months ago I had the painful experience of coming out of an engagement with someone I had known as my best friend for the past few years. It was a time when I could have easily imploded, but this time I tried to do a few things differently. The first has been intensifying my practice of yoga to discipline my body and watch my strength, flexibility, and balance grow better each day. The second was to start seeing a therapist and making the commitment of unraveling the big ball of neuroses that we all accumulate in the process of growing up. The third was my resolution to grow tobacco plants from seeds.

During the messier half of my twenties, I had an unhealthy cigarette smoking habit. After not smoking for more than 5 years, I decided to grow my own tobacco as a symbol of a lust I had conquered. If you’re the way I was when I first kicked the habit, you’re probably on the verge of gagging when you read the word “tobacco.” You’re thinking of the nauseating smell of stale tobacco permeating a heavy smoker’s clothes, their tainted teeth, fingernails, and breath. You’re thinking of one of the biggest cons of the last century, the tobacco giants and the victims they exploited for profits.

What surprised me most about growing and curing my own tobacco was how different it looks and smells  from the conventional stuff. How tobacco is cured (the horticultural term for “aging”) determines how mature tobacco looks, smells, and tastes. With each cured batch, the combination of humidity, light, and how long tobacco is left to age determines its final character. While I know, as a physician and scientist, that inhaling any burned organic material is harmful, my personal experience has also led me to believe that the 200+ chemicals added to cigarettes further contribute to cigarettes’ addictive potential and physical toxicity. Cigarettes were engineered to be as addictive as possible.

I’m a creature of habit. Growing tobacco taught me that the conditions under which seedlings germinate are very different than the conditions under which a seedling grows, which are different than the conditions that a mature plant needs to reach its full potential. While a little shade won’t hurt tobacco, other than stunting its growth a little, the plants are exquisitely sensitive to dehydration, reminding me every evening to give them the water they need to continue reaching for the sun, shedding their leaves at their ankles as they perpetually outstretch their crowns to the sky. Curing perfect tobacco requires experimentation and patience; the first time is awkward, the experience not fully satisfying, but once you find the right environment to let your freshly harvested leaves marinate in time, patience, and love, they will never disappoint. (I found one particular room in my home in the Bay Area where my tobacco ages beautifully.)

Grown by many indigenous people as well as by early European immigrants to North America, families of means grew tobacco on their property for personal consumption the way they would tomatoes or carrots. A good harvest meant enough tobacco to last the year, and a bad harvest meant no tobacco for personal consumption or gifting until the following year. Growing tobacco has made me a more patient man, a more devout lover, and a wiser soul. If growing one’s own tobacco is an act of love, then cigarettes are prostitution: love stripped down to a strictly physical experience.

As I step into the Indian Summer of my bachelorhood, I look around and realize how grateful I am to still be healthy and young. Being single again in the Bay Area has been an incredible experience, a realization that had escaped me while I was too busy comparing my life’s timeline and milestones to those of my friends. It’s harvest time, and as I pick the leaves off my tobaccos and hang them to dry, I’m surprised by a text from an old college friend. The last time I had heard from him, he had just married a beautiful young woman, and I expected a house, a golden retriever, and kids to follow. I remember thinking how far behind my life milestones I was; friends younger than I were getting married and having kids, and there I was still a medical student. He was now going through a bad divorce, his text read, 3 years after his Facebook’s relationship status had changed to “Married.”

The ritual of growing, harvesting, and curing tobacco helps me apply the same patience, devotion, and love to all my life’s endeavors. Like the tiny seeds that didn’t germinate until they had the right conditions, so too does the progression through each of life’s stages require the right conditions, without which a seedling will perish. And like the innumerable seedlings that suddenly sprouted from a bed of seeds, so too does one need to choose and focus on a handful of opportunities while discarding the rest, for too many seedlings can crowd one another and keep any one seedling from maturing into a plant. And like the handful of plants that grew into tobaccos, so too does each plant eventually need its own soil, water, and sunlight, or else it risks withering in the shade of its neighbors and casting its own shade on others.

Minimally Invasive Software

If I could gaze into my profession’s crystal ball when I was still a pre-med college student 10 years ago, I would have been stunned by contemporary doctors’ dysfunctional relationship with electronic health records (EHRs). I have more than a half-dozen free apps on my phone that empower me to video chat with friends and family continents away, cloud-based apps that let me create and share media-rich documents on any device — yet I’m stuck spending half my workday fighting with EHRs that look and function like mind-numbing spreadsheets. Not what I signed up for!

I grew up shadowing, and later working, in my father’s private medical practice and had the privilege of getting to know his patients and their families on a personal basis. When medical school exams kept me from spending my Saturdays in the office, my dad would come home and say over dinner, “By the way, Ms. Muller asked about you today,” as if she were an aunt asking about her nephew. His patients became in many ways a large, extended family that inspired me to devote my life to a profession I regard as sacrosanct. The work is selfless, the science fascinating, but what I love most are the personal connections I make with people everyday: sitting eye-to-eye and listening to others’ problems, fears, and dreams, and helping them live better lives.

It took me by surprise. While I was busy taking exams, a handful of EHR oligarchs emerged to save us from ourselves and our own handwriting. Hospital by hospital, clinic by clinic, our profession succumbed to “Spreadsheet Syndrome.”

Before entering Mr. Jones’ exam room, Dr. Patel glances at her EHR to see her patient in numbers: tabulated lab values, an archive of old notes, imaging reports, and test results. Laptop in hand, she enters Mr. Jones’ room, offers her hand and a tired smile, and immediately starts typing her note, checking and ordering tests, and entering prescriptions and referrals — while Mr Jones fades behind the wall of numbers on her screen.

I first heard of Amazon’s Echo while developing a voice-activated web app, in the context of an academic research project, which passively “listens” to a patient-physician encounter and delivers relevant reference information. My research mentor and I both thought that it might be interesting to port the app to Echo, and I invested $150 and a few weeks of time to build my first two Alexa “skills” (apps for Amazon Echo): a health tracker and a yoga coach (which has been used by more than 3,000 yoga fans at the time of this writing).

How software is designed profoundly influences how we think. I watch both amused and saddened as medical students and interns’ eyes glaze over endless rows of numbers only to find themselves drifting further and further away from their patients rather than actually knowing their patients. Instead of stopping by a patient’s room to ask him or her why they hospitalized last month when visiting their family in the Midwest, we find it easier to just review the EHR from the comfort of our desk. In the process of drowning healthcare professionals in minutia, EHRs obscure our ability to see the forest for the trees.

I believe strongly that the patient-physician conversation is the cornerstone of medicine. The best technology we can implement in the healthcare setting should be invisible – or as inconspicuous as possible.

One of my early endeavors along these lines was a Google Glass app (Vidrio) that passively “listened” and “watched” during patient-physician encounters to generated structured documentation from unstructured audio/video data. We won the 2014 MIT healthcare hackathon with this app, which was intended to liberate healthcare providers from the need to type their notes while interviewing patients. While my colleagues loved the concept (and countless doctors have asked me to pilot the app in their own practices), it seems to solve one problem while creating another. I’ll be the first to admit that I wouldn’t feel comfortable having a candid conversation with my own doctor if they wore a pair of Google Glass during the visit.

Rather than letting a device stand between patients and their doctors (literally and metaphorically), the Amazon Echo can quietly sit in the corner of an exam room, answer questions when called upon (“Alexa, give me a trend of Mr. Jones’ kidney function over the past year”…”Alexa, did Mr. Jones get his flu vaccine this year?”), then quietly fade out of the conversation. How’s that for minimally invasive software?

I’m working to save my profession from Spreadsheet Syndrome by helping doctors use Amazon Echo to interface with their EHRs. It’s about time we start using technology to help us spend more time doing the most important and satisfying part of our work: listening to our patients.

Omar Metwally, MD

Into the Ether: Walkthrough, Gotchas, and Tips for Ethereum Development

I’ve written countless lines of code in my life, but I’ve recently deployed code that will live forever. It resides on the Ethereum blockchain and can be executed decades from now, outliving any domain name I’ve ever purchased and outliving every internet company that has ever existed. Long after I pass away, when there’s no one to update the code base, no one to pay App Store fees, no one to renew domain names or pay server fees, this code will keep on running. This code runs not on a monolith tech company’s servers, but will run on millions — billions — of people’s computers, making it perpetual and unstoppable.

This is the promise of Ethereum, an emerging platform for decentralized, blockchain-based applications. The promise of a democratic, transparent, and decentralized Internet version 2.0 has fueled the skyrocketing price of Ether — the cryptocurrency powering the platform — from 4 Ether per Bitcoin (at the time of launch, about 1 Bitcoin was about $500) to $15 per Ether, an astronomical increase during the past 2 years. Ethereum can no longer be dismissed as a tech cult. While the world sleeps, household names such as Microsoft (which has incorporated Ethereum’s new Solidity programming language into Visual Studio) and JP Morgan Chase, recognizing how revolutionary the concept of Ethereum is, are investing in the vision. Ethereum has made headlines in the New York Times, and children of Ethereum such as The DAO (Decentralized Autonomous Organization) have also been featured in widely-read publications such as the Economist.

In this article, I offer practical pro-tips and gotchas for writing and submitting contracts on the Ethereum blockchain, along with a vision for Ethereum’s future. The process of running the Ethereum client will vary depending on which version of the client you use and your operating system. I’m a die-hard Linux user and prefer the Ethereum Go client over others; if you’re running Mac OS X or Windows (or another client), your experience will be slightly different.

You’ll note that both the Ethereum Wallet (Mist) and the Mix IDE are featured on the Ethereum homepage as graphical interfaces that allow users to create, debug, and deploy contracts. I eagerly await a mature version of the Mix IDE, as the current version is still in concept stage. I’ve always preferred command line to GUIs for the control and transparency they offer, and so, after experimenting with different clients, I ended up choosing the Go client.
The Ethereum website now has several handy code samples for things like creating a new currency, an autonomous organization with its own voting mechanisms, or launching a crowdsale — tasks conceivable only through the novelty of Ethereum’s decentralized structure. Running the simple “hello world” Greeter contract can be challenging for newbies. Here are a few tips that will hopefully get you up and running more quickly:

  1. After installing the geth client, follow these instructions to create a new account and remember the password! Remember it like your own name but guard it like your biggest secret.
  2. Now you’ll have to download the blockchain to your node. This process can take several hours and will begin once you run the geth command. The terminal will print out which block is being downloaded, and you can track your progress by comparing that block with the latest block on the chain.
  3. Once your node is updated, open another terminal window and enter geth attach. This opens the geth console while creating a single concurrent session between the two windows.
  4. Within the console, try eth.accounts to see your account addresses. You might want to copy these somewhere convenient but safe for your own reference. eth.getBalance(eth.accounts[0]) will print out the balance in wei (1^18 wei = 1 Ether). If your balance is zero, you will have to add Ether to your account before you can deploy contracts to the blockchain. Pro users can upload their presale wallets, or if you’re coming later to the game (or want to be cautious) you can buy Ether on an exchange such as Kraken and transfer Ether to your account address. This reddit post describes the process well. Note that after successfully transferring Ether (the transaction itself shouldn’t take more than a few seconds), your client will need to be fully synced to the network before eth.getBalance(eth.accounts[0]) command will show your updated balance. You can verify that your transaction was successful on this website by entering your address, while you’re waiting for your client to sync.
  5. Nice work if you’ve made it this far (it may take a few days, depending on your experience and if you already have Ether or a trading account). Now you can start deploying your contract to the blockchain so it can bask in immortality. Close all terminal windows, open a new one, and enter: geth –unlock=0 –password=”/path/to/your/password” where “/path/to/your/password” is a file containing nothing but your account password from step #1.
  6. Open another terminal window and enter geth attach. This will open the geth console. Then follow the steps in the Greeter tutorial to launch your first Hello, World! contract. Common reasons for not succeeding at first are not unlocking your account (or using the wrong account), not having enough Ether in your account, and not completely syncing the blockchain on your node. More precisely, you must have downloaded at least the block that contains the transaction in which you transferred Ether into your account (if this sentence doesn’t make sense, don’t worry — just sync your node and be patient while this happens) so your local Ethereum client can “see” the transaction.

After working through these steps and browsing StackExchange and Ethereum forums while you get up and running, the fun part really starts. So you’ve become a believer in Ethereum. You’ve even bought some Ether and deployed your first contract. The big question now is, what makes Ethereum a revolutionary act rather than just another blockchain startup based on yet another programming language called Solidity.


If you’ve ever read (and comprehended) Hofstadter’s Gödel, Escher, Bach: An Eternal Golden Braid, you’ll appreciate that meaning is intrinsically tied to form. Ethereum’s significance lies in the fact that Solidity is a Turing-complete language running on the blockchain. That is, it is entirely decentralized and contracts are fully transparent. I’ve jumped on innumerable hot new technologies and platforms in the 18 years I’ve been coding, some of which take off, many of which fizzle away in a cloud of hype. I believe that Ethereum may be one of the most substantial events I will witness in my life due to its form (i.e., a Turing-complete language running on a blockchain).
Surprisingly, several dozen Ethereum-powered dapps (as they’re called) are already live. Ethereum developers are still trying to wrap their heads around the essence — the form — of a dapp, which are largely in concept or early beta stages. The fact that Ethereum is not yet mainstream means that the pool of potential dapp users consists of a small number of tech savvy individuals, in contrast to the huge pool of iOS and Android users who can effortlessly download apps via the App Stores.


What many people, who don’t understand the technical underpinnings of the Ethereum Virtual Machine (EVM), don’t realize, is the following:

“Roughly, a good heuristic to use is that you will not be able to do anything on the EVM that you cannot do on a smartphone from 1999. Acceptable uses of the EVM include running business logic (“if this then that”) and verifying signatures and other cryptographic objects; at the upper limit of this are applications that verify parts of other blockchains (eg. a decentralized ether-to-bitcoin exchange); unacceptable uses include using the EVM as a file storage, email or text messaging system, anything to do with graphical interfaces, and applications best suited for cloud computing like genetic algorithms, graph analysis or machine learning.” (Ethereum Wiki)

Keep this in mind as you dream up your dapps, contracts, and DAOs. This isn’t just another app platform; this is Ethereum. To give birth to revolutionary ideas on the Ethereum blockchain, you need to respect its form.

I’m thrilled to be part of a small but growing community of dreamers writing code on the blockchain. What are you working on? Send me a line and let’s connect.
Omar Metwally, MD (@osmode)

Find me on LinkedIn
Read this on Quora
My consulting website

Doctor will work for Ether: Decentralized autonomous health insurance

Once Upon a Time a young man named Vitalik Buterin presented the concept of “Ethereum” to the cryptocurrency community. Vitalik became a Thiel Fellow and persuaded the world that there’s a better way to write laws, organize ourselves politically, and conduct transactions using a Turing-complete language built on the blockchain.

I would have never imagined, when I began developing on the Ethereum platform, that the concept of a decentralized autonomous organization (DAO) would make popular media headlines so soon. This is the start of something remarkable.

When I presented my vision for decentralized autonomous health insurance in June 2014 at the BitTorrent headquarters, Chris Peel, the founder of the Ethereum Bay Area Meetup, asked me how I would realize my vision. “Well…” I began, “operating health insurance is a big undertaking!” I said, scratching my head. Two years later, the time for a better way to insure our health and pay for health services is here. By cutting out the middle people, Ethereum-powered smart contracts and DAOs promise to dramatically reduce the cost of health services. Why should most of our outrageously over-priced health insurance premiums feed bloated corporations and their executives?

Ancient Chinese physicians practiced preventive medicine par excellence. In ancient China, physicians were compensated when their patients enjoyed good health, not when they grew ill – the opposite of our reactive, fee for service-based health system. Ethereum is our opportunity to end the healthcare crisis, and it’s incumbent on us to carry forth this effort.


Send me a line at

Omar Metwally MD

Carly, a voice-activated health coach for Amazon Echo


Since my team won MIT’s Hacking Medicine hackathon 2 years ago with an app that generates structured documentation from an unstructured patient-doctor interaction (by passively listening and watching the interaction), I’ve taken on the challenge of natural user interfaces. Recently, APIs such as Google’s WebSpeechAPI, which I’ve used in the setting of academic research, proved their ability to convert speech to text with enough fidelity to be useful in real-life applications. With devices like Amazon Echo and wide-range microphones capable of discerning speech through ambient noise, we’ve bypassed the second major hurdle in natural user interfaces.

Now it’s time to start bidding farewell to keyboards, mouses, and ugly software that looks like an Excel spreadsheet. Instead of scrolling through a mind-numbing list of vital signs and lab values in an electronic health record, a provider should simply be able to say: How high did John Doe’s blood pressure get in the past 4 hours? or Trend Jane Doe’s creatinine level over the past week. This is what I mean by natural language interface: software that allows humans to interact with it in the same way humans think, which is through natural speech.

If you have an Amazon Echo, check out my new Alexa Skill, Carly, a voice-activated health coach for Amazon Echo. The next stop will be introducing doctors to Carly and the joy of natural user interface.