Ethereum is an open-source software platform based on blockchain technology that enables developers to build and deploy decentralized applications (smart contracts).

Ethereum is essentially a world computer that is distributed between thousands of nodes. This computer of many distributed nodes is accessible to anyone, anywhere with Internet access. There are no membership requirements to address and it is truly a public blockchain.

The first public beta pre-release network was known as “Olympic.” The Olympic network provided users with a bug bounty of 25,000 Ethers for stress testing the limits of the Ethereum blockchain. “Ether” is the token utilized for using the Ethereum network.

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. Ethereum’s founders’ vision was to create an unstoppable censorship-resistant self-sustaining decentralized world computer.

For example, if you wanted to download Ethereum to your computer it will become an Ethereum ‘node’ on the network, running an Ethereum Virtual Machine(EVM), and will behaves equivalently to all the other nodes.

Note that Ethereum is a peer-to-peer network and there is no centralization and because of that all computers have equivalent status to other nodes.

Figure 1 shows the peer to peer decentralized network of Etheruem  

Figure 1 Decentralized network    

 

In the figure above we can see that the network nodes for Ethereum run the Ethereum Virtual Machine.  Note that the network structure is not flat or hierarchical like in common networking.

Ethereum Definitions

Like other blockchains and distributed ledgers, Ethereum has its own set of terminologies and definitions.

Dapps (decentralized applications) are essentially one or more smart contracts that are working together to run an Ethereum application. These applications run on a P2P network of computers, instead of one computer.

Ether is the native token of the Ethereum blockchain and is used to pay for transaction fees, miner rewards, and other services on the network.

Gas is a measurement roughly equivalent to computational steps for Ethereum. Every transaction is required to include a gas limit and a fee that it is willing to pay per gas; miners have the choice of including the transaction and collecting the fee or not. Every operation has a gas expenditure on an EVM. I will discuss Gas in more detail in Chapter 3, “Architecting Your Enterprise Blockchain.”

Node is a device, program, virtual machine that communicates with the Ethereum network. Nodes are also known as clients. A node runs the blockchain services and maintains the ledger.

Ethereum Blockchain Fundamentals

Ethereum is the blockchain platform and Ether is the token for using the Ethereum Virtual Machines on the Ethereum platform. Ethereum is a permission-less blockchain and a very different approach than the other blockchains we discussed early in the chapter.

While all blockchains have the ability to process code most of the blockchains are severely limited by restrictions. Ethereum approaches code differently by allowing developers to create whatever operations they want. This means developers can build thousands of different applications that go outside the typical blockchain structures.

Ethereum is known as the blockchain of blockchains.

Ethereum implements smart contracts which are usually deployed via distributed applications that are known as DApps

Distributed Applications, or simply “DApps”, are applications running directly on the blockchain. This way they are decentralized and not in the control of any one party. Their purpose is multi-fold, reaching from simple logic for p2p value transfers to complicated token structures and much more.

These smart contracts and Dapps work similarly from an application perspective as any other web application.

Figure 2 shows how the Dapps work from an API perspective.  

Figure 2: Example of an Ethereum Client Application Workflow      

           

From the figure above we can see that a client application would access an Ethereum application via HTTP protocol thru an Application Programming Interface(API). The smart contract would then be invoked and would run on the Ethereum Virtual Machine(EVM)

Because the economics and the logic are on the same layer it makes value transfer extremely easy.

You can save hardware and configuration by deploying the logic directly on the blockchain.

Bitcoin is called a blockchain 1.0, and Ethereum is called a blockchain 2.0.

Ether tokens are created by a schedule that was set by its 2014 pre-sale. Ether tokens are mined and thus require a miner. For example, 5 Ether tokens are created for every block mined, which is approximately every 15 seconds. These 5 Ether tokens are sent to the miners that mine the block. Ether can also be sent to another miner that participates in the transaction since it is possible that several miners compete for the mining of the blocks. Ether is considered the “fuel” that runs the Ethereum network.

Ethereum is the platform. Ether is the cryptocurrency built into the platform.

Proof of Work Mining

In Proof of Work (PoW) mining the miners compete to create valid blocks by spending electricity to find solutions to a mathematical puzzle. Ethereum’s PoW math’s challenge called “Ethash” works slightly differently to Bitcoin’s PoW mining. This allows common hardware to be used for mining and lowers the barrier to mining at least from a cost perspective.  The downside to this is that it reduces the efficiency edge of task-specific hardware known as ASICs, which are common in Bitcoin mining.

There is a plan to move from energy intensive Proof-of-Work mining to a more energy-efficient Proof-of-Stake protocol called Casper. This was scheduled to start to occur in 2018 and early 2019 but this was posted to several factors. Secondly, the updated version of the Ethereum software will be called Serenity.

Token Standards

In Ethereum tokens must adhere to token standards, which define a common list of protocols that an Ethereum token has to implement. The most common token standard is the ERC20 standard.

The ERC20 standard is basically a set of 6 functions that can be recognized and identified by other smart contracts for interactions with the smart contracts. Some of the functions are to get the total token supply or get the account balance of the wallet, etc.

This token standard allows developers the ability to program behavior of new tokens within the Ethereum ecosystem. Second, this approach is common with crowdfunding companies via Initial Coin Offerings (ICO). An ICO is a similar concept to an Initial Public Offering (IPO) in the stock markets.

You can find out more about Ether tokens at https://etherscan.io/tokens.

Ethereum Ledger

In Ethereum consensus is when the distributed ledger has been updated and all nodes maintain their own identical copy of the ledger. This architecture allows for a new capacity as a system of recordkeeping that goes beyond being a simple database. Blocks form a chain by referring to the hash or fingerprint of the previous block and are written to the ledger.

Remember that every node in the network holds a copy of the transaction and smart contract history of the network. The nodes also keep track of the current ‘state’ on the ledger.

Every time a user performs some action, all of the nodes on the network need to come to agreement that this change took place, and have it written to the ledger.

For example, every time a program (smart contract application) is used, a network of thousands of computers processes it. Contracts written in a smart contract-specific programming language are compiled into what is called ‘bytecode’ will be read by the ‘ethereum virtual machine’ (EVM) . Then all the nodes execute this contract using their EVMs which in turn update the ledger.

Ethereum Nodes EVM

The EVM (Ethereum Virtual Machine) is computer software that runs at an abstraction layer straight above the underlying hardware. Actual computation on the EVM is achieved through a stack-based bytecode language (the ones and zeroes that a machine can read), but developers can write smart contracts in high-level languages such as Solidity and Serpent that are easier for humans to read and write.

Ethereum uses a virtual machine to deploy the blockchain services on. The virtual machine type is considered a Turing Complete Virtual Machine that will run and compile the codes. The term “Turing Complete” states that this software is agile enough to run any code defined by the developer or user. We would consider this in the development world a flexible virtual machine.

Ethereum itself is only a protocol defining how the communication should work. It is neither a proprietary software, nor patent. Instead it is open and there are several different implementations of the Ethereum protocol.

Two of the most popular implementations are Go-Ethereum (or simply GETH), written in GO, and Parity, written in Rust.

Ethereum nodes communicate with each other using the Ethereum protocol. But, as with MySQL, for example, you can also connect to Ethereum nodes from the outside world. There are different ways to connect to an Ethereum node.

Usually you can, at least, connect via HTTP and IPC. Sometimes also WebSocket’s connections are supported. With HTTP, for example, the Ethereum node accepts requests in a JSON-RPC format. This is a standardized way of communicating with Ethereum nodes from clients. This way, any software that implements the JSON-RPC calls can connect to the blockchain via an Ethereum node. In other words, every Ethereum node must implement also a JSON-RPC interface.

Some important notes about Ethereum Virtual Machines:

  • The only limitation the EVM has that a typical Turing complete machine does not is that the EVM is intrinsically bound by gas. 
  • The power of the EVM is limited only by the amount of gas that is provided by the developer request.
  • The EVM is a stack-based VM which means that it uses an ordering structure that processes last-in-first-out in
  • The implementation for the smart contracts can be in Python, Java, C++  
  • Smart contracts when deployed are fully isolated from blockchain network which reduces vulnerabilities that could occur.

Figure 3 shows how the Ethereum Virtual Machines fit into the stack.

Figure 3: Ethereum Virtual Machine in the Ethereum Stack   

When joining the Ethereum network, you have some options from a blockchain node perspective:

  • Light nodes—Light nodes do not verify every block or transaction and do not have a copy of the current blockchain state.
  • Full nodes—Full nodes verify block that is broadcast onto the network.
  • Archive nodes—Archive nodes are full nodes that preserve the entire history of transactions.

Ethernode.org displays the current state of network nodes connected to the blockchain. At the time of writing, there were over 13,600 nodes. This site also displays the Main net and Testnet.

To find out the current Ethereum nodes on the blockchain, visit https://www.ethernodes.org/network/1.

Ethereum Client Apps

Developing applications to interface with the Ethereum APIs is very straightforward. Generally, the following frontend development languages are used with Ethereum:

  • HTML
  • CSS
  • JavaScript

The following backend tools are commonly used:

  • Solidity
  • Truffle

You can download Solidity or compile with your browser.

In Chapter 10 “Blockchain Development Hands On” I cover more details on these toolsets.

Solidity

Solidity is the development language behind Ethereum and is specifically designed to utilize the Ethereum Virtual Machine or EVM. Developers that are working on the Ethereum-based applications will be developing their smart contracts in Solidity.

Solidity uses a large number of programming concepts that exist in other languages. For example, Solidity has as you would expect in a programming language variable, functions, classes, arithmetic operations, string manipulation, etc.

Comparing Solidity to JavaScript:

  • Solidity is close to a type of an object-oriented language, like C++ and C#, whereas JavaScript is based on HTML programming.
  • Solidity is designed specifically for Ethereum applications and runs only on the Ethereum blockchain.
  • JavaScript is a universal language for the web and is being used in a large number of applications.

An Application Programming Interface (API) used with Ethereum is JSON. JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.

For your client application to talk to an Ethereum node from inside a JavaScript application, use the web3.js library, which gives a convenient interface for the RPC methods.

“Although the Ethereum blockchain is a public blockchain, it is great to see private and consortium blockchains using the Ethereum code base actively under development.” —Vitalik Buterin, Ethereum inventor (http://www.icofestival.de/post_220118.html)

Following are some additional toolset and applications used with Ethereum:

  • Languages—Solidity, Serpent, Mutant
  • IDEs—Solidity Browser, Ethereum Studio
  • Clients—geth, eth, parity, Ethereum Wallet
  • Storage—IPFS. Swarm and Storj
  • Dapp Browsers—Metamask or Mist
  • Testing—Testnet, TestRPC

Ethereum Transactions

Transactions in Ethereum is the way the external world interacting with the Ethereum network. A transaction is used when we wish to modify or update the state stored in the Ethereum network.

 Ethereum is an account-based blockchain implementation and this is different than other blockchains.

There are two types of account: Externally Owned Account(EOA) and Contract Account. An Externally Owned Account is similar to an individual user in the external world. This user in Ethereum network is represented by a 20-byte (160-bit) address.

The Contract Account has some similarities and differences. A Contract Account is created corresponding to a deployed contract. The Contract Account is identified by a Contract Address, just like in an EOA account is represented by a 20-byte address(160 bit). This is the address when we interact with this deployed account.

The Contract Account can also keep ethers when appropriate to the business logic. Contract is the “smart contract” capability in Ethereum network, where the business logic is implemented.

In the figure you can see that a user is initiating a web application hosted on the Ethereum. This is what would be expected when invoking an Ethereum application which would require Ether to be able to run an application on the Ethereum blockchain.

Chapter 4 “Understanding Enterprise Blockchain Consensus “provides a deeper dive into Ethereum consensus and how transactions are handled from a smart contract invocation.

Ethereum Smart Contracts

Smart contracts are contracts that can be converted to codes, stored, and, reproduced on the computer. Blockchain-based computer networks supervise smart contacts. With smart contracts, you can exchange money, shares, property and any valuable thing in a transparent way without the service of an intermediary. Smart contracts define the penalties and rules surrounding an agreement just like traditional contracts. Unlike traditional contracts, however, smart contracts also enforce the rules.

In Ethereum smart contracts are computer program code that is capable of facilitating, executing, and enforcing the negotiation or performance of an agreement using the Ethereum Virtual Machine. When we deploy several smart contracts together as an application, it would be known as a distributed application (a Dapp in Ethereum).

Smart Contracts in Ethereum provide some significant benefits to the users of the platform, including:

  • Autonomy
  • Trust
  • Backup 
  • Safety
  • Speed 
  • Savings 
  • Accuracy 

The basics of Ethereum state that all modifications to a contract’s data must be performed by its code. Modification of a contract’s data requires a blockchain user to send requests to its code. This process kickoff determines whether and how to fulfill those requests. Smart contracts on Ethereum network run on Ethereum Virtual Machine (EVM).

The Decentralized Applications (dApps) running on the Ethereum network are basically complex Smart Contracts.

Ethereum Smart Contracts have some properties to be aware of, especially when your development team is designing a smart contract for an application. Ethereum Smart Contracts are deployed in an automated fashion and can act as a complement to an agreement between two parties. Terms of the smart contract are recorded in a computer language as a set of instructions which are recorded to an immutable distributed ledger.

Smart Contracts when deployed on Ethereum will act a triggered event. For example, when a use sends funds of $100 to another Ethereum user to pay for tickets to a concert for example, the tickets will be sent only after the $100 is received from the buyer and deposited in the Sellers Ethereum wallet.  If the $100 is not received from the buyer, then the smart contact will not be triggered, and instructions executed.

Figure 3 shows the workflow of an Ethereum transaction.

Figure 3: Smart Contract Workflow

In the diagram above we can see there are four main steps to a transaction in Ethereum and each step must be executed properly for the next step to continue. Settlement of the transaction can only occur if the execution of the smart contracts occurs as programmed.

When writing smart contracts in Ethereum, developers use the programming language called Solidity. In Chapter 10 “Blockchain Development Hands On” I cover smart contracts and the basics of Solidity in more detail.

Ethereum is the most efficient and developed platform for decentralized applications.

Essentially, a smart contract in the implementation of Solidity is a collection of code and data that resides at a specific address on the Ethereum blockchain. Solidity is a programming language native to Ethereum that was specifically designed for Ethereum and was released to the development community in 2015″

For more on Solidity and Ethereum smart contracts, see Chapter 10.

Ethereum Wallets

One significant difference between Ethereum and the other enterprise blockchains is the fact that Ethereum is a permission-less platform and it also has a cryptocurrency (token) called Ether. Ether is the token that is used for running your smart contracts on the Ethereum platform. To send and receive Ether, you need to have a wallet.

A wallet is a program that allows you to gain access to, send, and receive bitcoins on the blockchain. There are several types of Ethereum wallets: hardware, software, and web.

Common Ethereum wallets include MyEtherwallet, Jaxx, and Metamask. You can also go to an online exchange, such as Coinbase and have an online wallet (www.coinbase.com).

%d bloggers like this: