Ethereum and Blockchain - 2


In the previous blog, I had described the origin of bitcoin and the various components of the Bitcoin network. Although conceptually Ethereum is very similar to Bitcoin, there are few differences.

Unlike Bitcoin protocol, Ethereum was designed to be adaptable and flexible. The nodes in Bitcoin network are simple software programs that validate a transaction and store a transaction, however, the nodes in the Ethereum network are fully functional Ethereum Virtual Machines which are capable of executing scripts of different algorithmic complexities.

Developers can develop programs which execute on EVM. These programs are written in a new javascript programming language called Solidity. Programs written in Solidity are compiled to EVM bytecode. The EVM acts as the runtime environment for these programs. These programs are completely sandboxed, and completely isolated. They don't have access to the file system, network or any other processes running on the same machine!

Like in Bitcoin, the Ethereum nodes also include the peer-to-peer protocol. The Ethereum blockchain database is maintained and updated by many nodes connected to the network. Each and every node of the network runs the EVM and executes the same instructions. The programs (written in Solidity) that you add to your node are propagated to all nodes within the Ethereum network and will be executed when the criteria for their execution are met. The programs written in Solidity are known as Smart Contracts. These programs are executed when certain criteria are met.

External programs can interact with the EVM client using the web3 interface. Web3 libraries expose various JSON RPC based methods which one can use to interact with the Ethereum clients.

Ethereum clients are differentiated as the main client and light client. Presently the EVM main client is available for all major desktop operating systems. While there are plans to develop light clients for smaller devices such as phones, IoT (Android-based light client) etc.

Ethereum Virtual Machine

The most popular Ethereum client is geth. The client has been developed in the Go programming language and implements the full functionalities of the EVM. The next most popular EVM client is cpp-ethereum/eth. This client has been developed in C++. You can follow the instructions of their installation from their Github links.

The full client will always maintain a local copy of the Ethereum blockchain database. So in case, your infrastructure isn't capable enough to hold that huge data, you can opt for a light client such as MetaMask. MetaMask is basically a Google Chrome add-on, which will interact with the Ethereum blockchain over the internet and fetch the data requested.

Mining: Like in Bitcoin network, transactions are validated using "proof of work" principle. However, the consensus algorithm used in this case is different from that of Bitcoin. Ethereum uses a hashing algorithm called Ethash. There are plans to replace this algorithm with a new one called Casper. More details on the consensus algorithm of Ethereum and the need for Casper/Proof-of-stake is explained in this video.

Ethereum supports different types of block chains namely: 
  • Public blockchain: is a blockchain that anyone can read, anyone can send transactions to and expect to see them included if they are valid, and anyone can participate in the consensus process – the process for determining what blocks get added to the chain and what the current state is.
  • Consortium blockchain: a consortium blockchain is a blockchain where the consensus process is controlled by a pre-selected set of nodes. A consortium might be a set of banks or financial institutions.
  • Private blockchain: a private blockchain is a blockchain where write permissions are kept centralized to one organization. Read permissions may be public or restricted to an arbitrary extent. 
And Ethereum client can be configured to connect to any of these block chains. However, at any point in time, one client can be connected to only one type of blockchain network.

Transaction cost: There is a cost involved in every transaction that's executed on the blockchain. This cost is expressed as gas units. The standard unit of currency in Ethereum network is ether, while the lowest denomination is wei.  

The total ether 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

Applications that interact with the Ethereum network are called as DApps - (Distributed Apps). These are basically programs like simple HTML/Javascript web applications that interact with the Ethereum blockchain. In the next blog, I shall document a real-world example of a DApp that I am going to build in Javascript. Then shall try recreating the same in Java as well.

PREV                                                                                                                                              NEXT

Popular posts from this blog

Setting up Private Ethereum TestNet

Ethereum and Blockchain - 1