- Node: A node in the blockchain ecosystem is any computer, mobile device or IoT device connected to the blockchain.
- Immutable: The data stored in the blockchain once, can never be altered or removed.tps: transactions per second.
- tps: transactions per second.
Blockchain is not only a complicated technology to work with but also to understand. This is an introductory article on blockchain technology. In this article, I will explain the basics of blockchain as simply as I can and give you a visualization of it for better understanding.
What is a Blockchain?
The blockchain is essentially a distributed database of transactions. The data stored in the blockchain is immutable, i.e. the transactions once written on the blockchain can never be undone.
Technically, blockchain is a collection of blocks linked together in sequential order. Every block of the blockchain stores transactional data. Each block can store less than or equal to a fixed amount of data which is known as its block size.
People generally confuse blockchain with cryptocurrencies, however, these two are very different things. Blockchain is a technology in itself, cryptocurrencies are a technology built on top of blockchain technology. In simple analogy "cryptocurrency to the blockchain is as email to the internet".
How are these blocks linked together?
A block can be divided into 2 parts i.e. Block Header and Block Body. The block Body contains the transactional data. The Merkle root of this transactional data is stored in the block header.
The Block header also contains the following data.
- The version of the block.
- Previous block hash
- Merkle root
(We will not cover all of these terms in this article)
All of this data is appended together and hashed to generate an alphanumeric string of fixed length. this string is known as the Block Hash. The subsequent block in the chain stores this block hash in its block header (as its previous block hash value) and this is how all the blocks are linked together.
How is blockchain decentralized yet secure?
There is no central server where all the blocks of the blockchain are stored. Instead, Blockchains do something crazier. All the nodes download the entire copy of the blockchain. Thus all the nodes are responsible for maintaining their own local blockchain database.
This raises some questions about security and maintaining a global state among all the nodes. Let's discover how blockchain solves this issue.
Blockchains incorporate a consensus algorithm through which the nodes achieve consensus to validate new blocks for the sequence. There are various consensus algorithms such as -
- Proof Of Work: validation based on solving a mathematical puzzle
- Proof Of Stake: validation based on the stake of the network participants.
- Proof Of Authority: validation based on the value of identities of trusted parties in the system.
Due to these fault-tolerant rigorous validation algorithms, entering fake blocks into the blockchain is next to impossible. These consensus mechanisms also help to maintain a global state among all nodes in the blockchain.
To enter fake data or change previous data the attacker needs to gain a majority in the network that agree on the fake data. A minimum of 51% majority is required. However, this process will require computation power more than that of 5 supercomputers combined. Therefore this attack is not feasible.
E.g. Suppose an attacker can compromise some of the nodes in the network and inject fake transactions in a block. The hash of that block will change therefore, the link will break. The nodes with the fake chain are in minority. Therefore, the system will still function properly.
How are new blocks added in the blockchain - the mining process?
New blocks are added to the blockchain by a process called Mining. Mining validates the transactions happening on the blockchain in exchange for a small cryptocurrency reward. The people who mine cryptocurrencies on their systems are known as miners.
The mining process is different for different consensus algorithms. Bitcoin and Ethereum use the Proof Of Work algorithm. In this algorithm when a new block is to be added miners compete with each other to find the Nonce value of the block which satisfies the required criteria. (E.g the criteria may be to find a nonce value for which the first 7 bits of the block hash are 0)
The miner who first find this nonce value shares it with other peer nodes. They verify the value and if it is correct they store it as the nonce value of the new block in their local blockchain. Repeating this process all the nodes in the blockchain add a new block to their local instance. The transactions contained in the new block are hence validated. The miner who found the nonce gets rewarded in cryptocurrency.
This is how new blocks are mined and transactions are validated.
A cryptocurrency is a digital or virtual currency that works on a blockchain. Cryptocurrencies are secured by cryptography which makes it impossible to do fake transactions or double spend.
Essentially a cryptocurrency is a piece of code that determines the value an address hold. The value of cryptocurrency is determined by its supply and demand in the market.
A feature of cryptocurrencies is that it is not regulated by banks or any central authority. Therefore any 2 entities in the world, connected to the blockchain can transact with each other without the involvement of banks and taxes. they only need to pay a small network fee and the transaction will be complete within a few minutes. 🙌
Type of blockchains
According to the level of centralization, blockchains are classified into 3 categories.
- Public blockchains: Public blockchains are open to all. any person can connect to the network and perform transactions on it. All the data of the blockchain is visible to everybody. All nodes are treated equally and have equal weightage in the transaction validation process. There are no special privileges.
- Private Blockchain: private blockchain are not open for everybody to join. Only a few members of a company/organization can join the blockchain. These blockchains incorporate an authentication scheme to prevent outsiders from participating in the network.
- Consortium Blockchains: These are similar to private blockchains, the only difference is that there are multiple organizations instead of one that governs the network.
Advantages of blockchain technology
All the transactions in the blockchain are visible to everybody.
Elimination of middlemen
Transactions can be done without the involvement of any bank or other middlemen.
Transactions are very difficult to tamper with and once validated, cannot be reverted.
Transactions on the blockchain are anonymous. The identity of peers involved in the transaction is unrevealed.
Although blockchain is a very promising technology in many aspects, it is not a silver bullet. It has its cons too.
High cost of mining
The cost of mining Bitcoin or Ethereum is very high. All the nodes competing to find the nonce first but failing are essentially wasting electricity. Therefore the cost of validating transactions is high.
Bitcoin e.g. processes 4.6tps. Visa on the other hand does 1700tps.
Record of uses in illicit activities
Anonymity is both a gift and a curse. For common people, using cryptocurrency is an escape from the eyes of their government, banks or other regulatory bodies, however, for criminals, it is an easy way to transfer funds for illegal activities.
Blockchains bring along both good and bad but it is a very powerful technology altogether. Starting from bitcoin, as merely a way of value exchange, blockchain has vastly expanded its capabilities in the past 2 decades and has become something much more.
Today we have much smarter blockchains like Ethereum, Eos, Polkadot etc on which we can build entire decentralized applications governed by smart contracts. This has given birth to many new industries, the hottest of which is Defi - Decentralized finance.
Many companies and developers all around the world are still speculating on the capabilities of this technology and still expanding its potential.
It will always be interesting to watch new industries getting revolutionized by this technology 🌟