A gentle introduction to Ethereum
Ethereum builds on blockchain and cryptocurrency concepts, so if you are not familiar with these, it’s worth reading a gentle introduction to bitcoin and a gentle introduction to blockchain technology first. This article assumes the reader has a basic familiarity with how Bitcoin works.
What is Ethereum?
Ethereum is software running on a network of computers that ensures that data and small computer programs called smart contracts are replicated and processed on all the computers on the network, without a central coordinator. The vision is to create an unstoppable censorship-resistant self-sustaining decentralised world computer. The official website is https://www.ethereum.org
It extends the blockchain concepts from Bitcoin which validates, stores, and replicates transaction data on many computers around the world (hence the term ‘distributed ledger’). Ethereum takes this one step further, and also runs computer code equivalently on many computers around the world.
What Bitcoin does for distributed data storage, Ethereum does for distributed data storage plus computations. The small computer programs being run are called smart contracts, and the contracts are run by participants on their machines using a sort of operating system called a “Ethereum Virtual Machine”.
How do you run Ethereum?
You can download (or write yourself if you have the patience) some software called an Ethereum client. Just like BitTorrent or Bitcoin, the Ethereum client will connect over the internet to other people’s computers running similar client software and start downloading the Ethereum blockchain from them to catch up. It will also independently validate that each block conforms to the Ethereum rules.
What does the Ethereum client software do? You can use it to:
- Connect to the Ethereum network
- Explore Ethereum’s blockchain
- Create new transactions and smart contracts
- Run smart contracts
- Mine for new blocks
Your computer becomes a ‘node’ on the network, running an Ethereum Virtual Machine, and behaves equivalently to all the other nodes. Remember in a peer-to-peer network there is no ‘master’ server and any computer has equivalent powers or status to any other.
How is Ethereum similar to Bitcoin?
I think it’s easiest to understand Ethereum by exploring the similarities and differences between Ethereum and a simpler system, Bitcoin. So what are the similarities?
Ethereum has a blockchain
Like Bitcoin, Ethereum has a blockchain, which contains blocks of data (transactions and smart contracts). The blocks are created or mined by some participants and distributed to other participants who validate them.
You can explore this blockchain here: https://etherscan.io
Blocks form a chain by referring to the hash or fingerprint of the previous block. See a gentle introduction to blockchain technology for a primer.
Ethereum is public and permissionless
Like Bitcoin, the main Ethereum network is a public, permissionless network – ie anyone can download or write some software to connect to the network and start creating transactions and smart contracts, validating them, and mining blocks without needing to log in or sign up with any other organisation.
In general, when people talk about Ethereum they mean the main public permissionless instance (version) of the network. However, like Bitcoin, you can take Ethereum software, modify it slightly and create private networks that aren’t connected to the main public network. The private tokens and smart contracts won’t be compatible with the public tokens though, for now. For more on the difference between public permissionless and private permissioned networks, see confused by blockchains? Revolution vs Evolution
Ethereum has Proof-of-Work (PoW) mining
Like Bitcoin, mining participants create valid blocks by spending electricity to find solutions to a mathematical puzzle. Ethereum’s PoW maths challenge called Ethash works slightly differently to Bitcoin’s, and this allows common hardware to be used for mining. This reduces the efficiency edge of task-specific hardware known as ASICs, which are common in Bitcoin mining.
For more on mining see a gentle introduction to bitcoin mining.
On Ethereum’s roadmap there is a plan to move from electricity-expensive Proof-of-Work mining to a more energy-efficient Proof-of-Stake protocol called Casper, in a future release of the Ethereum software called Serenity.
Ethereum has an inbuilt cryptocurrency
Ethereum’s token is called Ether, shortened to ETH. This is a cryptocurrency that can be traded for other cryptocurrencies or other sovereign currencies, just like BTC. Its current value is around US$13 per ETH token (Oct 2016). Token ownership is tracked on the Ethereum blockchain, just like BTC ownership is tracked on Bitcoin’s blockchain, though at a technical level they track them in slightly different ways.
For more on cryptocurrencies and tokens see a gentle introduction to digital tokens.
How is Ethereum different to Bitcoin?
This is where it gets more technical and in many ways more complex.
Ethereum’s block time is shorter
In Ethereum the time between blocks is around 14 seconds, compared with Bitcoin’s ~10 minutes. This means that on average if you made a Bitcoin transaction and an Ethereum transaction, the Ethereum transaction would be recorded into Ethereum’s blockchain faster than the Bitcoin transaction getting into Bitcoin’s blockchain. You could say Bitcoin writes to its database roughly every 10 minutes, whereas Ethereum writes to its database roughly every 14 seconds.
Ethereum has smaller blocks
In Bitcoin, the maximum block size is specified in bytes (currently 1 MB) whereas Ethereum’s block size is based on complexity of contracts being run – it’s known as a Gas limit per block, and the maximum can vary slightly from block to block.
Currently the maximum block size in Ethereum is around 1,500,000 Gas. Basic transactions or payments of ETH from one account to another (ie not a smart contract) have a complexity of 21,000 Gas so you can fit around 70 transactions into a block (1,500,000 / 21,000). In Bitcoin you currently get around 1,500-2,000 transactions in a block.
Data-wise currently most Ethereum blocks are under 2 KB in size.
The Ethereum Virtual Machine can run smart contracts
Compared with Bitcoin’s primitive scripting language, the code that can be deployed in Ethereum and run as smart contracts is more advanced and familiar to developers. Smart contract code is run by something called the Ethereum Virtual Machine, which runs on the computers of all participants on the network. If you are familiar with Microsoft Excel macros (pieces of code run by Excel), then similarly smart contracts are pieces of code run by Ethereum’s Virtual Machine.
In many descriptions, Ethereum smart contracts are called “Turing complete”. This means that they are fully functional and can perform any computation that you can do in any other programming language.
ETH token issuance
How are ETH tokens printed or created? The biggest difference between ETH and BTC token generation is that BTC generation halves approximately every 4 years whereas ETH generation continues to be generated at a constant number every year (perhaps only until the Serenity version).
This is a lot more complicated than Bitcoin. In summary, the number of ETH in existence are:
Pre-mine + Block rewards + Uncle rewards + Uncle referencing rewards
Around 72 million ETH were created for the crowdsale in July/Aug 2014. This is sometimes called a ‘pre-mine’. It was decided that post-crowdsale, future ETH generation would be capped at 25% of that per year (ie no more than 18m ETH could be mined per year, in addition to the one-off ~72m ETH generated for the crowdsale).
Currently each block mined creates 5 fresh ETH. Doing the maths, if a block is mined every 14 seconds, and there are 31.5m seconds in a year (365x24x60x60), this means 2.25m blocks are mined per year. 2.25m blocks at 5 ETH per block = 11.3m ETH generated per year. This meets the commitment of less than 18m ETH generated per year.
Actually it’s a little more than that. Some blocks are mined a little late and don’t form part of the main blockchain. In Bitcoin these are called ‘orphans’ and are entirely discarded, but in Ethereum they are called ‘uncles’ and can be referenced by later blocks. If uncles are referenced as uncles by a later block, they create about 4.375 ETH for the miner of the uncle (7/8th of the full 5 ETH reward). This is called the uncle reward. Currently around 500 uncles are created per day, adding an additional 2,000 ETH into circulation per day (~0.7m ETH per year at this rate).
Uncle referencing reward
And there’s a bit more too: A miner who references an uncle also gets about 0.15 ETH per uncle (maximum 2 uncles).
This model described above, where valid blocks are determined and miners are rewarded, is called the Ghost protocol (Greedy Heaviest-Observed Sub-Tree).
Future changes to ETH generation
It hasn’t really been decided yet what happens to issuance when Ethereum moves from Proof-of-Work (including the Ghost issuance rules) to Proof-of-Stake as the block-addition mechanism. The Proof-of-Stake mechanism will use a protocol called Casper (yes, as in the friendly ghost. Who says cryptonerds don’t have a sense of humour?). The rate of ETH issuance under Casper may very well be lower than it is now under Ghost.
So, what do miners get for mining?
In Bitcoin, the miner of a block receives:
- 12.5 new BTC (currently. See a gentle introduction to bitcoin mining for more detail), plus
- transaction fees from the transactions included in the block
In Ethereum, the miner of a block receives:
- 5 new ETH block reward (0r 4.375 new ETH for an uncle), plus
- a small new reward for referencing up to 2 recent uncles (1/32 of a block reward ie 1/32 x 5 ETH = 0.15625 new ETH per uncle), plus
- gas from contracts that were run during the block
Currently the average block has a gas limit of 1,500,000 Gas, and the network has an average Gas Price of 0.000 000 022 ETH, meaning that a miner might make 0.033 ETH in a ‘full’ block as the Gas reward. Note that the Gas from contracts are payments of existing ETH, not new ETH being created.
Other parts to Ethereum: Swarm and Whisper
Computers need to be able to calculate, store data, and communicate. For Ethereum to realise its vision as an unstoppable censorship-resistant self-sustaining decentralised ‘world’ computer, it needs to be able to do those three things fairly efficiently and in a robust way. The Ethereum Virtual Machine is just one component of the whole:
- The Ethereum Virtual Machine is the ‘calculate’ element that can run contract logic
- This is computation without relying on a central server.
- Swarm is Peer-to-Peer file sharing, similar to BitTorrent, but incentivised with micropayments of ETH. Files are split into chunks, distributed and stored with participating volunteers. These nodes that store and serve the chunks are compensated with ETH from those storing and retrieving the data.
- This is file storage without relying on a central server.
- Whisper is an encrypted messaging protocol that allows nodes to send messages directly to each other in a secure way and that also hides the sender and receiver from third party snoopers.
- This is communications without relying on a central server.
Smart contracts are little computer programs that are stored on Ethereum’s blockchain. They can be activated, or run, by funding them with some ETH. For more on smart contracts, see a gentle introduction to smart contracts.
Here’s an example smart contract, taken from Wikipedia:
In Ethereum you set up a smart contract by creating a new account with some code in it, and uploading it to the Ethereum blockchain in a transaction.
Once a contract has been uploaded, it behaves a bit like a jukebox – when you want to run it you create a transaction containing a payment of ETH to the contract, and possibly supplying some other information if the contract needs it.
Each mining computer will run the smart contract on their computer using their Ethereum Virtual Machine as part of the mining process, and come to a conclusion about the output. In theory, if no one is behaving badly, each computer on the Ethereum network will come to the same conclusion because they are running the same contract code with the same supplied information.
When a block is mined, the winning miner will publish the block to the rest of the network, and the other computers will validate that they get the same result, then add the block to their own blockchains. This is how the state of Ethereum’s blockchain gets updated.
In Bitcoin, there is a concept called address where bitcoins are stored – like a bank account number, but for bitcoins. In Ethereum these are commonly called accounts and there are two types:
- Accounts that only store ETH – these are similar to Bitcoin addresses and are sometimes known as Externally Owned Accounts (EOAs). You make payments from these accounts by signing transactions with the appropriate private key.
- Here’s an example of an account that stores ETH:
- Here’s an example of an account that stores ETH:
- Accounts that store ETH and have code (smart contracts) that can be run – these smart contracts are activated by a transaction sending ETH into it. Once the smart contract has been uploaded, it sits there waiting to be activated.
- Here’s an example of an account that has a smart contract:
- Here’s an example of an account that has a smart contract:
Uncles and Orphans: blocks that don’t quite make it
Ethereum’s rate of block generation is much higher than Bitcoin’s (250 blocks per hour on Ethereum vs 6 blocks per hour on Bitcoin). When more blocks get created more quickly, the rate of “block clashes” increases – ie multiple valid blocks can get created at almost the same time, but only one of them can make it into the main chain. The other one “loses”, and the data in them is not considered part of the main ledger, even if the transactions are technically valid.
In Bitcoin these non-mainchain blocks are called orphans or orphaned blocks and they do not form part of the main chain in any way and are never referenced again by any subsequent blocks.
In Ethereum they are called uncles. Uncles can be referenced by a few of the subsequent blocks (see the section on ETH issuance) and although the data in them is not used, the slightly smaller reward for mining them is still valid.
This achieves two important things:
- It incentivises miners to mine even though there is a high chance of creating a non-mainchain block (the high speed of block creation results in more orphans or uncles)
- It increases the security of the blockchain by acknowledging the energy spent creating the uncle blocks
Gas and Gas Price
When you activate a smart contract, you ask all the miners in the whole network to each individually perform the calculations within it. This costs them time and energy, and Gas is the mechanism by which you pay them for that service.
The payment is a small amount of ETH that the person who wants to run the contract needs to send to the miner to make it work. This is similar to putting a coin in a jukebox.
Payment (in ETH) = Gas amount (in Gas) x Gas price (in ETH/Gas)
The more complex the smart contract (the number and type of computational steps, memory used for storage, etc), then the more Gas the contract requires to run and complete. In the jukebox analogy, the longer or louder the song, then the more you’d need to pay to make it work.
Whereas the amount of Gas to run a contract is fixed for any specific contract, as determined by the complexity of the contract, the Gas Price is specified by the person who wants the contract to run, at the time they request it (a bit like Bitcoin transaction fees). Each miner will look at how generous the gas price is, and will determine whether they want to run the contract as part of the block. If you want miners to run your contract, you offer a high Gas Price. In this way it’s a competitive auction driven by how much someone is willing to pay to have a contract run.
Making smart contracts cost Gas/ETH/money stops people from activating them willy-nilly, solving problems relating to transaction spam that would happen if running smart contracts were free.
Just like 1 dollar can be split into 100 cents, and 1 BTC can be split into 100,000,000 satoshi, Ethereum too has its own unit naming convention.
The smallest unit is a wei and there are 1,000,000,000,000,000,000 of them per ETH. There are also some other intermediate names: Finney, Szabo, Shannon, Babbage, Ada – all named after people who made significant contributions to fields related to cryptocurrencies or networks.
Wei and Ether are the two most common denominations.
Smart Contract languages: Solidity / Serpent, LLL
There are three common languages smart contracts are written in, which can be compiled into smart contracts and run on Ethereum Virtual Machines. They are:
- Serpent – similar to the language Python, and was popular in the early history of Ethereum.
- LLL (Lisp Like Language) – similar to Lisp and was only really used in the very early days. It is probably the hardest to write in.
Ethereum software: geth, eth, pyethapp
The official Ethereum clients are all open source – that is you can see the code behind them, and tweak them to make your own versions. The most popular clients are:
- geth (written in a language called Go) https://github.com/ethereum/go-ethereum
- eth (written in C++) https://github.com/ethereum/cpp-ethereum
- pyethapp (written in Python) https://github.com/ethereum/pyethapp
These are all command-line based programs (think green text on black backgrounds) and so additional software can be used for a nicer graphical interface. Currently the official and most popular graphical one is Mist (https://github.com/ethereum/mist), which runs on top of geth or eth.
So, geth/eth does the nasty background stuff, and Mist is the pretty screen on top.
History: Ethereum Timeline
Vitalik Buterin described Ethereum as a concept in a White Paper in late 2013. This concept was developed by Dr. Gavin Wood who eventually published a technical Yellow Paper in April 2014. Since then, the development of Ethereum has been managed by a community of developers.
A crowdsale to fund development took place in July and August 2014, and the blockchain was went live on 30 July 2015.
The development team was funded by an online sale of ETH tokens during July to August 2014 where people could buy ETH tokens by paying in Bitcoin, at an initial fixed rate of 2000 ETH for 1 BTC (currently in Oct 2016 1 BTC will buy you 50 ETH on the open market).
Crowdsale participants sent bitcoins to a bitcoin address and received a wallet containing the number of ETH bought. Technical details are on Ethereum’s blog https://blog.ethereum.org/2014/07/22/launching-the-ether-sale/
A little over 60m ETH was sold this way for a little over 31,500 BTC, worth about US$18m at the time. An additional 20% (12m ETH) were created to fund development and the Ethereum Foundation.
Software Release codenames: Frontier / Homestead / Metropolis / Serenity
These are friendly names for versions of the core Ethereum software, a little like Apple’s OS X version names such as Mavericks, El Capitan, Sierra.
- Olympic (testnet): Launched May 2015 – a testing release where coins are not compatible with ‘real’ ETH. A testnet still runs in parallel to the main live network so that developers can test their code.
- Frontier: Launched 30 July 2015 – an initial live release with a way for people to mine ETH and build and run contracts.
- Homestead: Launched 14 March 2016 – some protocol changes, more stability.
- Metropolis: Future launch – moving from command-line to graphical interfaces.
- Serenity: Future launch – moving from Proof of Work to Proof of Stake (Casper).
The vision of the Ethereum’s development team is to build an unstoppable censorship-resistant self-sustaining decentralised world computer that can perform calculations, store data, and allow communications.
There is a public permissionless open source version, and forks or copies of this have been taken and adapted for private network use. The public and private versions are attempting to solve different problems.
The technology is currently immature, but as more people use it, test it, develop it and build on it, it will improve and become more robust.
Ethereum is one of the most exciting technologies in the Blockchain space, so keep following its progress!
3 Oct update: A few people have commented that I have not written about The DAO (“Decentralised Autonomous Organisation”) – a specific smart contract that acted liked a crowd-based venture capital fund. The funds in the smart contract were drained by a hacker who took advantage of sloppy smart contract coding. I also didn’t mention Ethereum Classic, an alternative public blockchain which split off from the main Ethereum-core-developer-supported chain on 20 Jul 2016 as a response to the hacking of The DAO. Classic has separate tokens called ETC, sharing a common ancestry with ETH prior to block 1,920,000). This article is intended to be an introduction to Ethereum, and those two topics are more advanced and are covered in my book, The Basics of Bitcoins and Blockchains.
Update: I have recently published a book, The Basics of Bitcoins and Blockchains which contains an updated version of this blog post and much, much more.
The Basics is an essential guide for anyone who needs to learn about cryptocurrencies, ICOs, and business blockchains. Written in plain English, it provides a balanced and hype-free grounding in the essential concepts behind the revolutionary technology. You can pre-order “The Basics of Bitcoins and Blockchains” now on Amazon: https://amzn.to/2rNB1EQ