One might have come across the word “transaction” several times if they made an attempt to read on blockchain. Transactions are inseparable entities when blockchain comes into the talk point. What exactly are transactions? How are they processed in a blockchain network? These are the questions every enthusiasts checks on if they are newbies in the subject. This article gives you a detailed description of the entire journey of a transaction in a blockchain.
With no further ado, let’s get started.
The basic definition to a transaction in a blockchain goes something like this. It refers to the communication between the peers which are recorded in the distributed ledger. It may include money transfer, asset transfer, deploying a code, or even an execution of a code.
For a better note, let’s take an example of a financial transaction. Assume that Alice needs to transfer 10000 INR to Bob.
Before head to the blockchain way of processing, let’s firstly look at the steps involved in a traditional online banking for processing this transaction. Here is it:
As you can see, here the transaction is processed by a single third party, the bank server. So the Alice and Bob are “trusting” a centralized system for carrying out the transaction.
This might look very simple and straight, however, there are certain issues to serious look at. For instance, the question is….. Can we fully trust the third party ? What if the bank server crashes ? What if some intruder manages to hack the system and tamper with the transactions ? How can we be so sure that our money would be safe? The questions are many on the centralized mode of banking transactions.
Now, let’s see how a similar transaction is processed in a blockchain network. For that, assume Alice needs to transfer 5 cryptocurrency to Bob.
Here the steps are a bit different. Instead of a bank server, Alice will log in to her wallet, enter the Bob’s account number and amount to be transferred. This data will then be verified by the node which receives the Alice’s transaction (local verification).
In a blockchain-powered system, if the transaction is found invalid, it will be discarded immediately. In case the local verification is successful, then the transaction will be broadcasted to all the nodes in the blockchain network.
Every node will then verify the transaction. If the transaction is found valid, each node will broadcast it to all other nodes in the network. A node may receive multiple copies of the same transaction from different nodes. However, it considers only one of them discarding the rest.
The nodes will keep the verified transactions in a local waiting area called transaction pool / mempool. During mining, the nodes will select some transactions from the mempool and assemble them into a block.
The nodes will then independently decide the transactions to be included in the current block. The selection may be based on several factors like time of the transaction arrival, transaction fees associated with a transaction and so on. So the block created by each node may consists of a different set of transactions.
Later, based on a consensus algorithm, the winner node is selected. The block created by the winner will be broadcasted among the nodes in the network.
Nodes will compare the transactions which are included in the new block with those in their mempool. The transactions which are included in the block will be removed from the mempool.
Once the block is added to the blockchain, Bob will get his first confirmation and his account will be credited with 5 cryptocurrency.
Unlike the previous example, here a decentralized system is used to carry out the transactions in blockchain. We aren’t depending on a “trusted” third party in blockchain eliminating the “single point of failure” maniac. Here, in a blockchain network, the entire network holds the account details and verifies the transactions. Even if some of the nodes fail or act maliciously, the network still contains the copies of the data within the rest.
A blockchain network consists of thousands of nodes, therefore, it is unlikely that the entire network may crash or an intruder may influence the majority of the network and tamper with the data.
Decentralization allows transparency. The transaction history is stored in a public ledger which allows one to easily verify their transactions. The distributed nature backed by strong cryptographic techniques provide improved security and makes the blockchain network tamper-proof.