Introduction to development on Ethereum

Ethereum – a Decentralised Consensus Network

To most developers, learning to use a new platform, language, or framework will be a familiar task repeated dozens of times during their career. Altogether more novel is learning to develop for a completely different paradigm. The decentralised consensus network, the blockchain, and its most well known implementation ‘bitcoin’ are not well understood even amongst the tech community and the subtleties of how this technology is fundamentally different from what we have used before is certainly lost on most of the general public.

With that in mind before we proceed with building our first decentralised apps I will outline a few of the key technologies that are required to make a decentralised consensus network, and the game theory which makes use of these technologies to create a network.

Public-private key cryptography is a class of encryption methods that require the creation of two separate keys; the “private key” known only to the owner, and the “public key” which is known to anyone. It has several useful attributes, the first is the ability of anyone to encrypt data with a public key that can only be decrypted by the private key. The second is the ability of the private key holder to sign a piece of information using their private key in such a way that it can be verified by anyone holding the public key, without giving any information away about the private key. This second attribute is used for the accounts system in a DCN, and forms the basis of sending transactions.

A hash function is a function that takes one piece of information of any size and maps it to another piece of data of a fixed size i.e. a 1MB file or a 500KB file when run through a hash function would produce two separate ‘hashes’ 128 bits in length. A Cryptographic Hash Function is one that performs this function but also fulfils three important requirements: it does so in a way that no information is given on what input data produced the hash (non reversible), it does so in a way that a minor change in the input change gives a very different output hash, that the hash cannot be calculated except using the hash function (no shortcuts), that there is an extremely low probability that two different inputs will produce the same hash.

Unlike the Client Server model peer-to-peer networks consist of networks of computers connected to one another directly without sending requests to any server. All computers taking part in the network are considered to be ‘peers’ and have equal standing within the network as one another. Peer to Peer networks generally rely on the peers being altruistic and sharing at least as many resources as they take from the network

A blockchain in all it’s incarnations is a database type designed specifically for use in a DCN. It can hold any information, and can set rules on how information is updated. Its primary feature is that it is updated in discrete chunks called ‘blocks’ which are ‘chained’ together using hashes of the previous blocks content. A blockchain contains not only the information that is currently stored in the database, but also every change made to the database in its history. Known as the state and transactions respectively it makes for a database with a complete custodial history that cannot be altered without altering every subsequent block. A private key always signs ‘Transactions’ or requests to change the state of the database, and the signature is stored in the blockchain.

Originally envisioned as a spam prevention system proof of work is a simple method for proving that you have *probably* performed a large number of mathematical operations. It is implemented in the majority of cases using a cryptographic hash function; given an arbitrary piece of data, (like a list of transactions and the header of a block) you must find a second piece of data which, when combined with the first, produces a hash that has certain characteristics (like a number of trailing zeros). Because it is impossible to predict what second piece of data will produce the required hash, you must randomly iterate through possible data until you find one that produces the hash you require.

Ethereum Technologies

Ethereum Virtual Machine

The Ethereum Virtual Machine is the primary innovation of the Ethereum project. This is a virtual machine designed to be run by all participants in a peer to peer network, it can read and write to a blockchain both executable code and data, Verify digital signatures, and is able to run code in a quasi-Turing complete manner. It will only execute code when it receives a message verified by a digital signature, and the information stored on the blockchain tells it is appropriate to do so.

The Decentralized Consensus Network and the Generalised Blockchain

Ethereum is a peer to peer network where every peer stores the same copy of a blockchain database and runs an Ethereum virtual machine to maintain and alter it’s state. Proof of work is integrated into the blockchain technology by making the creation of a new block require all members of the network undertake the proof of work. Consensus is achieved via incentivization for peers to always accept the longest chain of blocks in the blockchain by distribution of a cryptographic token of value: ‘ether’.

This leaves us with a new piece of technology that does not fit within the client-server model nor does it qualify as a traditional peer-to-peer network as its existence is incentivised meaning it can be relied upon to provide a consistent deterministic service.

Because of its distributed nature and built in cryptographic security it can act as a third party, capable of arbitrating trustlessly, and without interference from outside parties. Through the use of cryptocurrencies decisions made by software can have financial consequences for people, organisations or even other software.

This provides developers with new ways to enable interactions between parties across the Internet. While I explain the subtleties of the development of decentralized-apps I will give use cases and try my best to explain the importance of each one.