Ethereum and Bitcoin differences (Blockchain Dev Primer)

I recently decided to start a new journey as a Blockchain developer. I found the differences between Ethereum and Bitcoin architecture key in bootstrapping myself into the Blockchain development space. Relax, I won’t tell you that Blockchain is a distributed ledger. I wrote this blog to share what I think is key to look at when starting Blockchain development.

What this blog is not about

This blog is not about whether you should or shouldn’t invest in bitcoin or any other form of crypto- currency.

Bitcoin architecture

In this section I will delve into the Bitcoin architecture and attempt to summarise it. I suggest you read the bitcoin white paper, if you haven’t already. This will make it easier to follow.

Key Components

  • Platform

The core application of blockchain runs on an application platform of a network of distributed servers/nodes. This is essentially what is referred to as the distributed ledger. It is shared by all the servers/nodes. Note that each node may run the entire blockchain if it’s running the core application i.e. the blockchain software.

  • Nodes

As alluded to above, nodes are distributed. They use the P2P protocol to collectively process tasks as “equals”.  They achieve this using a  consensus mechanism . Bitcoin specifically uses the Proof of Work consensus mechanism. The consensus mechanism is used to determine how nodes agree on blockchain updates. With that said, there are several node types that are part of a blockchain application.  Nodes of type Miners ensure transactions are confirmed and included in the blockchain. The Miner node is key to the blockchain as it plays the role of securing the network by means of making the network extremely hard and computationally expensive to compromise.

  • Transaction

This is a type of record on the blockchain. A transaction can be created on behalf of a client using, for example a mobile wallet. The transaction will contain the actual data to be stored on the blockchain.

  • Blocks

This is another type of record on the blockchain. A Block records the sequence of transactions in the blockchain. Transactions are logged onto the blockchain based on specific sequences. These Blocks are created by miners.

  • Chain

The Blocks described above are then chained together. As depicted by the diagram below, the blocks from transactions are added to a chain which essentially represents the distributed ledger. Once blocks are added to a chain, the transactions from that block are complete and permanent.

Transaction model

Bitcoin uses the unspent transaction output (UTXO) for its transactions. Basically, each transaction has an input and an output. The input is where the money came from and the output is where the money is sent. The UTXO is essentially input that has not been spent ie. no real output of bitcoin.

Now, you can’t spend a fraction of the UTXO. So, let’s say Bob sends Tom 1btc. Tom will have input of 1btc and output of 1btc UTXO. After a few days Tom decides to send Zee 0.5btc, which is a fraction of his UTXO (1btc). Tom can’t send a fraction of his UTXO, so he creates a new transaction such that he sends the whole UTXO (1btc) and receives change of 0.5btc.  This is called creating a change address. The wallets that exist currently do this for you under the hook, so you would not have to worry about explicitly doing this as a user who is buying/spending bitcoin. In this manner, the blockchain can validate transactions and enable extracting of balances.

Ethereum blockchain architecture

In this section I will delve into the Ethereum blockchain architecture and attempt to summarise it. I suggest that you read the Ethereum white paper, if you haven’t already. This will make it easier to follow.

Ethereum is very much Bitcoin inspired, hence architecturally it’s close to Bitcoin. It has its own Blockchain and is architected to be more programmable and extensible (Turing-complete).  Ethereum does this by building an abstraction of a blockchain that uses a Turing-complete programming language. This means that anyone can write smart contracts, and decentralised apps where they can create their own rules of ownership.

Key components

  • Database

This component is responsible for storing all transaction in the blockchain. The data stored is immutable. The transactions are also public, so anyone can see them and verify them. Like the Bitcoin, Ethereum uses the Proof of Work consensus mechanism to ensure that all nodes in the network have the same copy and the network is secure.

  • Code

This is where all the logic sits ie. the application code/smart contracts. This code can be written in languages such as Solidity, Viper, LLL and others. Essentially the Ethereum blockchain stores transactions and contract code which gets executed by the Ethereum Virtual Machine(EVM).

Below is a diagram from zastrin that depicts the Ethereum architecture. The web3js component is used to connect to your blockchain node. This means you can simply build your own UI and access your blockchain via web3js which you will include in your UI.

Transaction model

Ethereum uses objects called accounts to handle state of transactions and balances. Transactions are then fired from accounts. So, whenever an account receives a transaction, its code gets executed according to input sent as part of the transaction. The code is executed on each node on the network by the EVM as part of their verification of new blocks.

The use of accounts makes the transactions stateful unlike with Bitcoin where a UTXO can either be spent or unspent. The diagram below depicts how state is maintained using Ethereum’s state transition function. A transaction is a signed data package that stores a message to be sent from externally owned accounts to another account on the blockchain. The message exists only in the Ethereum execution environment and is like a virtual object. A message is created only by a contract, hence not from any external actor. Ethereum uses gas to charge for computational power used for execution of verification. Hudson Jameson gives a deeper explanation of this concept.

Key differences in architectures

Ethereum Bitcoin

 

Language integrated which makes it Turing complete Limited functionality with its scripting language (stack-based language)
Smart contract lives in its own address Smart contract lives within the transaction
Has two account types Has one account type
Uses ethash as hashing algorithm Uses SHA-256 as hashing algorithm
Purpose for a platform to enable running and developing Dapps Purpose for alternative money, ie. cryptocurrencies

 

Conclusion

Ethereum architecture is based on the Bitcoin architecture with a difference in purpose really. Bitcoin is solely focused on alternative money, whereas Ethereum envisages a platform for creating and running distributed applications, for e.g. you could develop and run a voting application on Ethereum using its underlying blockchain. In addition, it also offers alternative money in Ether.

I found that reading and understanding the concepts discussed in earlier sections gave me wholistic view as a Developer. Once you understand these concepts you can then go deeper into understanding the implementation of blockchain for example scripting in Bitcoin and why it is known as a weaker version of smart contracts.  At this point it is advisable to start buying some crypto currencies to understand the ecosystem better. I have started to play with geth, a go implementation of Ethereum.

References

BlockchainGeek. (n.d.). Blockchain-consensus. Retrieved from https://blockgeeks.com/guides/blockchain-consensus/

Github. (n.d.). Ethereum white paper. Retrieved from https://github.com/ethereum/wiki/wiki/White-Paper

Nakamoto, S. (n.d.). Bitcoin. Retrieved from https://bitcoin.org/en/bitcoin-paper

US, M. C. (n.d.). 51% attack. Retrieved from https://medium.com/coinmonks/what-is-a-51-attack-or-double-spend-attack-aa108db63474

Wikipedia. (n.d.). Proof of Work. Retrieved from https://en.wikipedia.org/wiki/Proof-of-work_system

Zastrin. (n.d.). blockchain architecture. Retrieved from https://www.zastrin.com/

by Mthokozisi Myeza

RMB FOUNDeRY

Author RMB FOUNDeRY

More posts by RMB FOUNDeRY