Introduction to Blockchain

This article serves as an introduction to Blockchain technology, specifically the Bitcoin Blockchain.

Table of contents.

  1. Introduction.
  2. How UTXOs are Created.
  3. Blocks.
  4. Links between Blocks.
  5. Advantages and Disadvantages of a Blockchain.
  6. Summary.
  7. References.

Introduction

Unlike banks or other traditional forms of record-keeping where we have accounts and balances, cryptocurrency(Bitcoin) holders only have wallets with addresses that serve as interfaces to the blockchain. Also instead of combining transactions into a single sum, bitcoin stores all transactions as individual transactions. Just like a wallet storing individual notes and coins that sum up to a number.

For example, the following is an example of a Bitcoin wallet.

bit109

Bitcoin and other blockchain protocols store transactions performed on the network and user balances in the form of UTXOs. These are lists of unspent bitcoins sent to a user but not sent from him/her.
On the bitcoin blockchain, transactions appear as a collection of bitcoins on different addresses, a user uses a wallet to be able to access the bitcoins. A transaction is said to be valid if a user can prove ownership of the Bitcoins using keys stored in a digital wallet.
This makes it easy to track a bitcoin since it is signed from one party to another.

On the other hand, the Ethereum blockchain stores information about a user, and account balances are subtracted and added to give balances in accounts as a single transaction. This although efficient, makes it hard to track transactions. In other words, we can track every transaction whether it be a sender sending money to a recipient or the recipient combining the wallet balances to form a single balance on the Bitcoin blockchain. On Ethereum, a transaction is said to be valid if a user proves ownership of the account and the balance is enough to perform a transaction.

A UTXO(Unspent Transaction Output) is a piece of Bitcoin that can be combined and split to make bitcoin payments in all denominations just like a note being split into coins to make payments. They are just like physical currency but there are not standardized, meaning one can have any amount of bitcoin i.e we can have 0.005 Bitcoin but not $0.005.

A UTXO is both the input and output of a bitcoin transaction. An output exists as a UTXO until it is spent as input in a subsequent transaction.
A UTXO set set is the set of all existing UTXOs at a specific time.
Participant nodes in the network are responsible for storing all UTXOs in a distributed decentralized database/ledger.

Structure of a UTXO

  • Unique id of transaction that created the UTXO.
  • Index of the UTX in the transaction output list.
  • A value/amount.
  • An optional condition under which the output can be spent.

A Transaction will include:

  • A reference number of the current transaction
  • References to one or more input UTXOs
  • References to one or more output UTXOs that are newly generated by the current transaction.
  • The total input and output amount

How UTXOs are Created.

The UTXO model enables bitcoin to be more transparent, auditable, and better than centralized financial systems that rely on bank balances, and other third parties. It is a digital cash economy.

Let's compare the account model for bank institutions and the UTXO model in Bitcoin. If Bob has 2 BTC and sends Alice 1 BTC. Now Alice has 1 BTC from Bob and Bob has 1 BTC remaining. The bitcoin blockchain notes that Bob signed over 1 BTC to Alice. Now the difference comes. Assuming Alice had 2 BTC, now she has 3 BTC, another transaction is needed to convert her 2 BTC into 3 BTC by adding the 1 BTC sent from Bob. Similar to how converting two $1 notes to a single $2 note requires a transaction.

On the other hand on the Etherium blockchain, Alice would automatically have 3 ETH once Bob sends her 1 ETH. The blockchain would note that Alice's balance has increased and Bob's balance has decreased. In this case, no extra transaction is needed to combine Alice's account sum.

This is one of the reasons among others Bitcoin uses more computing power(electricity) for mining compared to Ethereum. Also why it is more valuable, if all transactions are recorded, then it is difficult to cheat the system.

An example of a bitcoin transaction

The following is an example of a Bitcoin transaction found here
bit110-1

We break it down as follows;

  • We have a transaction hash of 22bb5dd2a88f9c5183df59aef20a44b...
  • We also have the following 3 input UTXOs referenced and their corresponding two output UTXOs.

bit111

Now, why do we have 3 inputs and 2 outputs? The reason is that the three input UTXOs are used(spent) to generate the two output UTXOs.

At the time of this writing the total amount of Bitcoin transacted summed up to $148, that is;

  • $49.56 was paid to a user with a wallet address 19knNTypKHmMS8SUEL3qoppxNaY5fjXbMQ
  • $39.12 to 1NThiEZspn5Avi9pi52ARV8vw6Lr77VUpJ
  • $60.3 to 12mNFc8sr4FZMQ9ts4injJPtYn97h768ZC

The transaction fee paid to the miner who validated this particular transaction was paid a fee of $55.

For more information, we can scroll down the page and decipher the information to know more about the inputs and outputs in a Bitcoin transaction.

Blocks.

A genesis block is the first block to be mined at the beginning of a blockchain network. In this case, the first bitcoin block to be mined was by Satoshi Nakamoto, it can be found here

Bitcoin started here, it was started when Satoshi initiated the first transaction with a reward of 50 BTC. It was started just as people had lost faith in the banking system

The following image shows the genesis block mined by Satoshi Nakamoto.
bit101-1

The system was designed in a way that if the wallet address is lost, then 50 BTC cannot be spent or used.

We can generate our genesis block and start a toy blockchain.

bit112

On the blockchain tab, in the first block, once we enter some data and mine. Notice how the hash changes, all other subsequent blocks also need to be mined so that the hash can match the hash of the previous block. Also notice that the genesis block has no previous block that it links to, this is the genesis block.

We can also try to change a block already in the chain. Notice how all other subsequent blocks become red. This means they are invalid, more mining has to be done to validate them. In the real thing, once this happens, it is a sign that someone has tried to change a transaction, in this case, others will invalidate the block and remove it from the chain until the transaction is rectified.

Links between Blocks.

From the image in the previous section, we have the following 3 blocks, blocks, 1, 2, and 3.

Block 1.
bit113-1

Block 2.
bit114-1

Block 3.
bit115-1

A shallow analysis of the three images shows us that the previous hash of block 2 is the hash of block 1 and the hash of block number 2 is the previous hash at block 3. Also notice that the genesis block does not have a previous hash. These blocks link together to form a blockchain.

Advantages and Disadvantages of a Blockchain.

Since the creation of blockchain technology, we have seen many advantages such as increased security in trustless environments such as supply chains, and finance among others. Blockchain has also had its disadvantages such as increased storage capacity.
In this section we look at the pros and cons of blockchains;

Pros of blockchains

  • In a blockchain data is stored on distributed databases or servers distributed across the globe meaning that if a single server is down, it does not affect the network in any way. Blockchains use a peer-to-peer network whereby nodes in the blockchain are directly connected to each other and communicate with each other.

  • Blockchains are trustless systems in that their participants rely on the mathematical algorithms to work as expected compared to centralized systems such as banks where users had to put trust in the management of the bank which time and again failed. In blockchains such as Ethereum, we have smart contracts which ensure that operations are fulfilled, these contracts are very hard to change. In addition to that, there are consensus mechanisms that ensure that all parties act in good faith otherwise they are penalized. In summary, blockchains are very hard to cheat or corrupt because '1 + 1 will always equal 2'.

  • Once a block in a blockchain has been mined and confirmed by all miners, it is very difficult to change it or its contents. This feature of blockchains makes it a very useful technology in industries such as finance and supply chains where an audit trail is needed. In such industries, all records are recorded and stored permanently on the blockchain.

Cons of blockchains

  • A blockchain might be a peer-to-peer network but if 51% of the peers of the network are a single resourceful entity, then we are in trouble because this entity can change the records and invalidate the honest nodes. This is theoretically possible but very hard to happen on large blockchain networks such as Bitcoin, in such a case, the cost of initiating such an attack is more costly than the rewards the executor stands to gain.

  • As we said in the pros, once data is written it cannot be changed. This makes it very hard to change the blockchain even if it is for valid reasons such as upgrading the software. For example, if a soft fork has been implemented and later the implementors figure out it was a bad idea, it is impossible to go back. Also, there are cases of hard forks where nodes are invalidated because they ignore new changes to the blockchain. In other words, blockchain requires a lot of planning and thinking ahead before any change is made, this is the reason we have BIP(Bitcoin Improvement Proposals) and EIP(Ethereum Improvement Proposals).

  • Blockchains such as Bitcoin that use the Proof of Work consensus mechanism require a lot of energy. In that, all miners use a lot of electric power and computational resources to get the chance to mine a block but after 10 minutes a single miner is selected meaning the rest wasted their electricity. Bitcoin mining consumes more electric power than countries such as Denmark, and Ireland among others.

  • Blockchains store data and once written it is never erased, this means as time goes by, the disk size needed to host a blockchain will increase. For example, for one to start a Bitcoin full node, he/she needs to keep 200GB worth of disk space.

Summary.

Transactions involve the transfer of value in the bitcoin blockchain, UTXOs specify the inputs and outputs of such transactions.
When a block has been verified by the miners, as we can see no block in the chain can tell its tale, all other blocks must come to a consensus to verify a block before it is added to the chain.
The UTXO model enables bitcoin to be more transparent, auditable, and better than centralized financial systems that rely on bank balances, and other third parties. It is a digital cash economy.
A genesis block is the first block to be mined at the beginning of a blockchain network.

References.

The Genesis Block