Solidity and the Ethereum Virtual Machine

Welcome to the first decentralized global computational machine.

Over the past couple weeks I have been reading the Homestead release notes, the Solidity Documentation, watching youtube videos about Ethereum; really just an all out effort on trying to understand what this protocol is and why it is a technological successor to Bitcoin. In trying to explain it to others(or even write about it on here) I come to the notion that it is:

A global cryptographic, decentralized, immutable, permissionless world computer.

And in relation to the protocols of that which it is built on.

Internet = Communications

Bitcoin = Money

Ethereum = Computation

Without the Internet Bitcoin could have never existed and without Bitcoin, Ethereum could have never existed.

Now that’s a bold claim but I’m willing to make in that I truly believe that the predecessor technology has enabled this new paradigm in decentralized computing.

Bitcoin has and will continue to enable an unimaginable number of new and disruptive applications which will impact a number of verticals. I use my Shift card every day, wake up and check the price with an eye half open, and I anticipate my full attention will be back as we approach The Halvening. But right now, I want to learn how to write Smart Contracts in the Solidity programming language. I want to know how these contracts are compiled onto the Ethereum Virtual Machine (EVM). And how this is powering the next generation of peer-to-peer technology.

Installation and Setup

Download the latest Ethereum Wallet

Install Mix IDE, the IDE for authoring Smart Contracts using the High Level Language Solidity.

Program Solidity contracts on Visual Studio

You can also use the Online Compiler

The Ethereum Computer

The EVM is stack-based execution environment that uses Smart Contracts (similar to object-oriented classes) and HTML, CSS, and JavaScript to create dApps. When you are running a decentralized application (dApp), every instruction is executed on every node of the network. This means the operands for the instructions are taken from the stack, and it is also where the results are added. This is the low level assembly code of the EVM and the resulting flow-control functions that can be found in the Ethereum Yellow Paper. Items are pushed to the Stack and can be manipulated using POP (remove top item from the stack), SWAP (Swap item order on the stack / Limit of 16 elements), and DUP (copy and order new item on top of the stack).

Memory and Calldata

The stack also extends Memory and Calldata to be used in during program execution. Memory is an expandable byte-array used to store data during program execution. It can be accessed using the MSTORE and MLOAD instructions. Calldata is a byte-array, just like memory, but it is read-only. It contains the data from the transaction that triggered the code execution in the Contract.


Storage is a map used for fields in contracts. A contract can neither write nor read any storage other that its own. Essentially it is permanently storing the state variables within the contract.

Elements of the Ethereum Smart Contract

Contracts in Solidity are similar to classes in object-oriented languages. Each contract can contain declarations of:

  • State Variables
  • Functions
  • Function Modifiers
  • Events
  • Structs Types
  • Enum Types

with Parameters of:

  • The gas-price I want to pay (gasPrice).
  • The maximum amount of gas that may be spent (gas).
  • The amount of ether I want to transfer (value).
  • My account address (from).
  • The target account address (to).
  • The nonce (nonce).
  • The transaction data (data).

A smart contract’s code resides in a Contract Account. It is unalterable once deployed.

Accounts in Ethereum

There are two kinds of accounts on the Ethereum network: Externally Owned Accounts (Public-Private Key) and Contract Accounts.

Externally Owned Account (EOAs): an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send ether and messages from it.

  • Can have an Ether balance.
  • Can send transactions.
  • Are controlled by private keys.
  • Has no code.

Contract Accounts (CA): an account that has its own code, and is controlled by code.

  • Can have an Ether balance.
  • Can send transactions.
  • Can send messages.
  • Contracts are controlled by their contract code.
  • Only send transactions in response to other transactions that they have received. Therefore, all action on the Ethereum blockchain is set in motion by transactions fired from Externally Owned Accounts.
  • Every time a contract account receives a transaction its code activates, allowing it to read and write to internal storage and send other transactions/messages or create contracts.

EOA0 —-Transaction–> CA1 = Activate Code in CA1

CA1 —– Messages —> CA2, CA3, CA4= Perform functions in CA2, CA3, CA4

EOA1 —– Transaction —-> EOA2 = Send Ether EOA2


Ether, the currency used in Ethereum, is exchanged for computation on the platform. Gas is the name for the execution fee for every operation made on an Ethereum blockchain. Its price is expressed in ether and it’s decided by the miners, which can refuse to process transaction with less than a certain gas price. To get gas you simply need to add ether to your account. The Ethereum client automatically converts Ether to gas and gas to Ether when transactions are processed.


When a transaction is sent from an EOA to a CA, it is sent with input code and Ether. The input code and ether is then processed by the Contract Account, thereby activating itself and thus executes its code. A CA can then send a message out to other (CA) contracts.The contracts are essentially talking and passing messages between themselves, in this way, sending a message is exactly like calling a function. This could produce another smart contract, send Ether to another address, register a vote of confidence, open a door to a house; virtually any sort of call to or update to the state of the decentralized network.

The total cost of a transaction is based on 2 factors:

  • gasUsed is the total gas that is consumed by the transaction
  • gasPrice price (in ether) of one unit of gas specified in the transaction

Total cost = gasUsed * gasPrice

An EOA can also send a transaction to another EOA and nothing happens accept transfer some Ether (P2P payment or ether).


Visit the Solidity website to see example Smart Contracts and write and edit them within your wallet. You will be able to use Electron by Shapeshift to deposit bitcoin in exchange for Ether so you pay the mining fee and begin deploying your first smart contracts.

Start with the following three example smart contracts.

Create a cryptocurrency

Crowdfund your idea

Create a DAO

A new block is created every 15 seconds in Ethereum. Essentially you are sending binary data to invoke state transition rules through EVM bytecode at the assembly level thus updating the distributed state of the blockchain; AKA deploying your Smart Contract.

Mining Ether = Securing the Network = Verifying Computation on the Global Computer

Next: 3 RaspPi3’s, 32GB SD cards each a running the Ethereum computer (Web3.0, next-generation peer-to-peer technology platform) running on each…

Final Thoughts

Watch Ethereum for Dummies – Dr. Gavin Wood

A global cryptographic, decentralized, immutable, permissionless world computer.

Internet = Communications

Bitcoin = Finance

Etheruem = Computation


This thing is AWESOME! I have been deploying contracts, sending transactions, and it’s all (near) real time. I can create a couple wallets and a couple cryptocurrencies and exchange them back and forth all confirming within 12 confirmations < a minute or 2. It’s pretty wild to keep the network stats up on on one screen the Wallet on the other and see them contracts confirm. Working on the front end now, possibly Salesforce integration + React.


Ethereum White Paper

Ethereum Yellow Paper


The Rise of Ethereum

The decentralized nature of cryptocurrencies are their biggest strength and their biggest weakness.

Often this is the case with something that completely disrupts the status-quo. The fact that decentralized currencies are open source also creates a unique situation where that which is the best given path or fork in the long run must be agreed upon and adopted by all (or a majority of miners in this case). However, when the consensus is not achieved at the level of those who truly are driving the development, alternatives rise. This is the case with the current rise of the Ethereum platform and the current value of Ether. In terms of the number of Dapps emerging, the amount of R&D investment at the enterprise level (IBM, Azure), and of course the current rise in Coin value; Ethereum is quickly becoming the more robust, more promising, and ultimately the more intriguing blockchain for developers, investors, traders, and anyone who has seen the evolution of blockchain technology and cryptocurrencies.

Does this mean that Bitcoin is done? Absolutely not. Bitcoin is still in it’s infancy and leads the pack in mining power, market cap, investment, startups, and overall global interest. The scalability issue is one which overall means that the network is working, in an unprecedented way it is really the first instance of a decentralized global consensus protocol. The question is not how do we mitigate risk with as some will say changing the path of a couple billion dollar plane inflight, but instead, how do we make Bitcoin, the global decentralized currency of the world, work. How do we enable people to build on the platform, host a node that’s relaying transactions and strengthening the network, run a miner that’s off the energy grid.

This could mean as some have proposed increase a block size from 1MB to 2MB to address an immediate issue. Or increase the blocksize in tiers over time so that the network scales. But I think the block size debate is missing the point. We need to think more in terms of off chain solutions.Examples such as, Tierion, embedding the Merkle Root of data into the blockchain, or Payment Channels and the Lightning Network facilitating offchain transactions between two parties with only an open and close broadcasted to the network, 21 building the ubiquitous machine payment layer and true micropayments ecosystem; these are types of companies and solutions that I believe will make Bitcoin the cryptocurrency of the world, work and serve as self-evident.

Again, that does not mean that other blockchains and more platforms like Ethereum will not emerge (Lisk). It is now very evident that private blockchains, within institutions will definitely serve a place in the years to come. In addition to this, sidechains will also serve to make the entire cryptocurrency ecosystem more robust. I truly believe in the statement that Intranet (oracle installation) vs Internet is an anology for blockchains(R3) vs The Blockchain. When you have an open protocol that is globally accessible, there is an unlimited and unimaginable number of potential future applications that will arise. This does not mean that internal blockchains developed by the existing financial ecosystem will not create new innovative processes and solve enterprise problems. But, the intrinsic value in having an open protocol for the world to build on especially when it comes to fintech and the tipping point we are at with the developing world onboarding into the digital age, I believe The Blockchain truly is more promising. I still am betting long on Bitcoin and I do hope that some sort of consensus is achieved amongst the core developers in order to enable people around the world to embrace this technology. Until that happens, I am buying more Ether.

Check out the new Ethereum Homestead Release





Distributed Consensus Protocols

Blockchain technology is the greatest computational advancement we have seen in the past 5 years. In terms of available information, real-time market effects, network effects, sentiment, research, feedback loops for price, volume, transaction levels; there is currently nothing as open and riveting. It is a new distributed database that can potentially be the foundation for an unlimited range of decentralized applications.

How can a decentralized database be that disruptive and what enterprise problems does it solve?

The more you look at blockchain technology, the more you learn about all of the adjacent fields needed to get a full understanding of what the technology actually is. It could be learning law, cryptography, economics, finance, psychology the list goes on. It is really profound that I am reading  or even rereading whitepapers now to understand or get to the bottom level of a certain blockchain application. Even reading through a piece of legislation and commenting on what cybersecurity and auditing concerns could be actually be addressed through using the blockchain. 

So before I go any further, what is the blockchain?

A blockchain is a timestamped transaction ledger. What this means is it is a record of a chronological series of transactions that a network of nodes distribute to each other. The first instance of a blockchain was Bitcoin. A bitcoin unit in a blockchain represents an unspent transaction output that is written to a globally distributed, replicated, undeletable, timestamped database. It simply means that anyone in the world gets the same answer when querying the system. The value in this technology is that anything can be etched into this type of ledger to create a distributed consensus protocol. This could be money, title, copyright, notarization, real-time triple entry accounting, data storage, stocks, votes, digital or tokenized physical assets; it’s essentially creating a distributed proof of ownership that is logically centralized and organizationally decentralized. Before the blockchain, there was no sort of computational system that enabled this.

 Organizationally centralized Organizationally decentralized
Logically centralized eg Paypal Blockchains (Bitcoin)
Logically decentralized eg Excel eg e-mail

Chart Source: (

  • A decentralized transaction network
  • A store of value
  • A callable global ledger

This ledger can be referred to by people and machines enabling p2p, b2b, and m2m transactions from a decentralized global distributed consensus protocol.

Let’s take a look at the different Distributed Consensus Protocols:

Bitcoin and Blockstream

Let’s start with Blockstream, the Bitcoin blockchain and sidechains. Blockstream is a company which aims to create pegged sidechains. This would ultimately make Bitcoin the global reserve currency of all of the other cryptochains. Sidechains would enable a way to transfer value between chains for faster confirmation times, different unit accounts and different specific use cases. The value of the coin would be transferred from the bitcoin blockchain to the sidechain creating a stasis of the original coin. The coin now on the sidechain can move to other sidechains and transverse back to the Bitcoin blockchain activating the original coin again on the Bitcoin blockchain. No separate platform, just multiple blockchains interconnected with the Bitcoin blockchain and each other.

Counterparty and Hyperledger

Counterparty and Hyperledger are both enabling users to create and issue their own assets.

Counterparty is a platform and wallet built on top of the Bitcoin blockchain that enables user created assets through tokenization. Counterparty has it’s own coin called XCP.  The currency is used on the platform to create assets and users can also create smart contracts on the Counterparty platform that execute through a fee of XCP. These assets are divisible and callable. This means that once tokenized, the asset can be sold in division down to 8 decimal places and called back at a certain price of XCP at a certain point in time established when the asset is orginally issued. The asset can be sent from one users address to the others in many different ways such as a bet, a CFD, a dividend, an order, creating a situation where the counterparty risk is avoided.

Hyperledger is an open source project that is creating a decentralized ledger platform that represents assets. It registers the ownership of the asset through a network of distributed  nodes creating a callable and cryptographically secure ledger. Each asset has its own ledger. The ledger can be a public international ledger or a private ledger with a limited number number of users. The main difference with Hyperledger is there is no native currency, no blockchain, and the confirmation time is a few seconds. When a message is sent over the platform, nodes relay the transaction. If 2/3 of the nodes agree upon the validity of the transaction is it confirmed. The platform allows users to engage in p2p transfers of ownership whether it be a user created currency, a financial instrument, or the rights to a physical assets.

Ethereum and Eris

Eris and Ethereum are both platforms that enable the creation of various types of decentralized distributed applications.

Ethereum is a scripting platform that enables distributed applications and smart contracts. The Ethereum platform has its native currency, ether, which is used as a primary liquidity  layer and for transaction fees to execute the code in the smart contracts. This cryptofuel to the platform is used in Turing-complete scripts that enable the transfer of any type of  programmable asset  or arbitrary consensus-based application. The logic is written in code and embedded in the platform creating a state transition system based upon met or unmet value inputs and outputs from outside data sources or other contracts. Any imaginable contract, application, organization, or protocol that can be expressed logically in code can be built on top of Ethereum.

Eris is a framework that aims to enable the creation and effective use of server-less distributed web applications. Each application uses a distributed blockchain created on the Ethereum network as the server to achieve a shared consensus state that can be referred to. The application’s user interface is built using html, css, and javascript; essentially any sort of existing web application can be recreated on the Eris platform. A forum, a crowdfunding website, a social network, a marketplace. Within each application, Ethereum smart contract models are built and reused to manage the reputation of users and enable levels of functionality based upon the user’s activity and contributions to the application. The contracts are executed on the application’s blockchain using ether creating an organization that can function autonomously and facilitate decentralized decision making.

In conclusion:

Asset creation built from the Bitcoin blockchain = Sidechains

Asset creation built off the Bitcoin blockchain = Counterparty

Asset ledger creation built on distributed nodes = Hyperledger

Application and smart contract creation = Ethereum

Application framework built on top of Ethereum = Eris

Maybe I am still a little evangelical; it’s the foundation for a new age of computing, a shift in the paradigm for database security, the emergence of distributed consensus protocols.


A simple model to make sense of the proliferation of distributed ledger, smart contract and cryptocurrency projects

The Power of The Blockchain: Future Developments and Applications

Talent hits a target others can’t hit, Genius hits a target others can’t see. – Arthur Schopenhauer

The sentiment surrounding Bitcoin has transformed. It has gone from being known as the anonymous payment mechanism to facilitate illegal transactions, to a speculative digital bubble with no intrinsic value, to what industry leaders are now calling the greatest and most disruptive technological breakthrough since the Internet.

The paradigm has shifted, entrepreneurs and world-class venture capitalist firms are teaming up to improve the efficiency and effectiveness of this new payment ecosystem through:

  • online exchanges
  • single-signature wallets
  • multi-signature wallets
  • merchant integration services
  • B2B enterprise solutions
  • mobile user applications

So far, what has been built is a secure and effective means to “pay” someone else without the need for a third party. It is simply a global transfer of ownership mechanism using a mathematically distributed digital asset that is growing in scarcity because of an increase in the awareness of its namespace and purposiveness. It is a decentralized peer-2-peer transfer of ownership protocol using a consensus timestamping mechanism, and ultimately, it works.

The underlying technology that facilitates the transfer of Bitcoins, the blockchain, the namespace not in the headlines, is what will transform almost every domestic and international vertical market. The blockchain is intrinsically powerful in that it is the backbone of this new type of open source, verifiable, distributed mechanism of transfer and record. It is the “third-party” that is needed in so many of our modern trust base models for various goods and services. It is the “universal balance sheet” used to record and verify the most recent state of various digital ownerships.

The blockchain is the foundation for so much more than just a payment network the same way the internet is the foundation for so much more than just e-mail. If the blockchain is what’s important, then “Bitcoin” is simply the global onloading mechanism. It is the first tier, an introduction to a new age of what is possible through decentralized networking and computing.

Tier 1: A Decentralized Digital Currency and Payment Network

  • Why is Bitcoin being developed in the form of multiple online exchanges and wallets based on geographical location and currency?
  • What if there was one was global exchange that allowed anyone to buy and sell any form of digital or physical asset regardless of location in world?
  • How could a global asset exchange such as this increase the security, transparency, and efficiency of global finance and trade?

Tier 2: Decentralized Networks and Development Platforms

  • Why are digital currencies the only things being built up on top of this blockchain technology?
  • What if anything that could logically be expressed in code could be implemented on a blockchain?
  • How could this type of network and platform be adopted by the global economy?

This concept has the namespace of Ethereum, Eris (on Ethereum), Colored Coins, “Smart Contracts”, Bitcoin 2.0, and “side-chains”.

The crux of this whole phenomenon is that “Bitcoin” is a currency application to the blockchain.

Ethereum wants to make it so ANY type of deal, organization, service, or system, can be decentralized. It just requires the parties involved to set the parameters expressed in code. So what will be built on top of the Ethereum network for consensus verification?

Third-party Trust Models

  • Real Estate escrow between parties can be implemented using multi signature contracts.
  • Insurance Policies can be engrained in the blockchain.

Digital Commodity Pricing

  • Commodities pegged at consensus-aggregated value

Weather Based Contracts

  • Contract premiums based on season conditions.
  • A Farmer makes an insurance agreement based upon rainfall data.

File and Data Storage

  • Proof of Existence on Bitcoin Blockchain
  • Dropbox / Box type cloud storage
  • Enterprise storage, buy space from others on the network

Smart Contracts and Escrow

  • Hedging accountability
  • No option of default


  • Docusign
  • Multisignature to set proportional abilities on access to assets given certain number of keys

Private Keys to Share Economy Assets

  • Home and Apartment Leases
  • Home and Apartment Keys
  • Hotel Keys


  • Car and Ride Leases
  • Car and Ride Keys
  • Autonomous Vehicles
  • Safety Deposit Box Keys
  • Package Delivery Key

Permits to Controlled Assets

  • Guns
  • Prescriptions
  • Timestamped verifiable access

Audit and Financial Services

  • Taxes
  • Returns

Gambling and Betting

  • Proof of a Bet
  • Undisbutable

APIs with Global Mobile Banking

  • MPesa
  • WeChat
  • Alipay

Non-Disclosure Agreements

  • Timestamped Verification

Patents, Copyrights, and Trademarks

  • Timestamped Intellectual Property Rights

Payment Processors

DAOs (Decentralized Autonomous Organizations)

  • An organization run and bound by code.

Domain Names

  • Namecoin
    • First to exist
    • ICANN Replacement


  • Opt-In
  • Laws consensus driven

Voting Systems and Records

Reputation Systems 

Online Identification Systems and Records

Medical Records

Incentivized Truth Consensus Crowdsourcing

  • Range of n inputs for a sought after accurate condition or state of n, correct answers is rewarded x

What is actually enabling individuals to trade any amount of Bitcoin regardless of their location in the world is … “mining”. 
The cryptographic time-stamping mechanism that replaces centralized authority with community consensus. The blockchain needs miners to survive. It needs nodes to verify valid blocks with valid transactions. But what if the mining becomes centralized thus, Bitcoin becomes centralized? It is now self-evident to anyone who has been following the development of this cryptocurrency that the “mining” and “the blockchain” is what really matters.

The incentivized mining mechanism is what should make this ecosystem thrive, not the companies building a new type of wallet or security feature. 
 User adoption isn’t people buying up, holding and dumping after a price increase, it’s about people mining, becoming another node therefore increasing the security and transaction volume capacity of the network. It’s them realizing they can be part of a truly empowering decentralized global network. The network effect is what makes this technology powerful, its functionality as a type of distributed consensus technology increases overtime.

So the Bitcoin blockchain is being “mined” for a currency because it’s catching on, people are starting to accept it, online and offline. There is incentive.For all of these other future blockchain applications to work, you need people to mine “ether” from the Ethereum blockchain. I don’t know if I will be able to spend “ether” anytime around the corner but the important thing is that if given the right incentives, a blockchain has the potential to become very powerful.

Create incentive for people to decentralize a type of process:


Create a platform that allows people to decentralize any type of process:


Additional Reading on this:

Decentralized Asset Exchanges

The next layer on top of the Bitcoin protocol is real time asset distribution information, consensus , and public ledger. Stocks, bonds, real-estate, escrow, microloans, gambling, crowdfunding and P2P contracts will be executed on decentralized networks. This has been referred to as colored coins or designated digital “contracts” by a new protocol named Ethereum. Ethereum is a platform, a scripting language, and ultimately a new decentralized system for developers around the world to build with. This can be any sort of deal, contract, exchange that can be mathematically expressed in code. It enables the parties to set the terms in a publicly verifiable and protected transaction. This can revolutionize the way the internet of money serves as self evident. There is an even greater application that will emerge from these types of systems. This is the DAO, or Decentralized Autonomous Organization.

Imagine a corporation 20 years from now that is completely automated, checked and balanced in its management by computer code, providing a service that is globally accessible. This is the DAO. An organization that relies on the network and the programmers pivoting with hacks that maximize the user experience and delegate operations more efficiently to the computer system. Developers around the world can instill Artificial Intelligence into a publicly traded corporation, a voting system, or even a manufacturing facility.  The open source system will enable people to effectively build an organization with code, set it in motion, and delegate operations to machines and data servers around the world.

The value in a decentralized distributed system such as Ethereum is that anyone with an apparatus verifying contracts is now an additional node on network. Marc Andreesen of Andreesen Horowitz predicted that chip manufactures will soon start building chips that can support an OS and mine. An ever growing network of nodes, in every electronic device, verifying contracts between two people or within autonomous organizations. It is truly empowering to acquire the skills to build on a platform like Ethereum. It is an essential technological intermediate for what decentralized protocols like Bitcoin will enable in the future.

For more information about Etheruem you can read the white paper here.

Colored Coins video