Beginners Guide to Blockchain
Unless you are living inside a cave, it’s very hard to not hear the word “Web3”, “Blockchain” or “Ethereum”. Mostly because of a lot of negative things (negative sells right!) which are happening in this space (yes talking about hacks) but the core logic is often just overlooked and nobody takes time to understand and realize how everything works beautifully and makes this network, most secured we have till date.
Think for a while, every digital thing that we use today is governed by a central entity which can do anything, they can suspend a particular user from ever using that app or they can just promote a particular piece of content to be seen more as compared to some other piece of content. This is fairly common and known, but the repercussions aren’t deadly except in some cases.
But what isn’t fairly known is the same thing could be done with the money you hold in your bank account and it’s not like it has never happened in the past. The financial institutions that control our money are all closed and centralized systems. We trust them to make fair use of that power but sometimes they end up using this power for wrong purposes therefore, especially in cases of money it makes sense to have something open which isn’t owned by anybody and at the same time keep sure that all the rules are still followed. Before blockchain, it was a problem but after Satoshi Nakamoto’s paper on Bitcoin, things changed and we discovered a way to implement an open trustless system which can represent value.
Now let’s dive into what an open, trustless system actually means rather than just throwing them at you.
- By open, we mean a system where there is no more siloed, close data controlled by a bunch of intermediaries. Everyone gets to own their data.
- By trustless, we mean when the intermediaries are gone. We can create a system that is controlled by individuals, rules are set by computers which can’t be broken. Basically, a way to automate intermediaries. It’s a system you can trust to store your money account balances and stuff like that, computers are going to set the rules, so you can trust them, if your blockchain supports programs then smart contracts (basically a contract which is run by computers) are going to set what rules are set.
Blockchain can truly represent the value digitally because the data is going to be distributed and secured across the network, everyone is going to have a copy of data and everyone can see if there is a change in data. Transparency like never before.
What is blockchain?
Blockchain does a lot of things or responsibilities it handles and that’s why its combination or you can say has different ways of defining it. In total, blockchain can be thought of as a combination of 3 things:
- Network: it’s a network in the sense that, it’s a public network which anyone can access, you just need the internet to connect to a blockchain
- Database: it’s a database because it stores information on it which shared among different computers
- Computer: it’s a computer because it has computational overhead or uses computational resources to run programs (not all but some blockchains do support programs).
Now that we have established some common ground on what blockchain is, let’s discuss each one of them one by one.
Now you see, blockchain is a network which anyone can join but what’s different is this time, once you are on the blockchain network you become the user of the whole network not just the user of some app that you’re used to, what I mean by that is if you signup for google you become a user of google but being a member of google doesn’t mean you’re also a member of Facebook right, you have to signup to Facebook the same way you did it for google. But it’s different in blockchain, once you get onto the network you become a member of the network, your data gets stored on the network and you have access to everything on the network. Now similar to how you need an account on google to use their services, you need an account on the blockchain too which essentially is your address (also commonly known as wallet address), this address represents you on the blockchain.
You connect to a network via a single node to access the entire network, so illy a URL which lets you connect to the entire network. You can run this node yourself or can use someone else’s.
Moving on to the shared database, now anyone who is a user of the network has access to this database. This database consists of transactions, what’s a transaction? Anytime something happens on the blockchain it creates a transaction, you can think of it like a record in a traditional database (MongoDB, or any DB of a similar sort). The thing where a transaction differs from the traditional database is it’s immutable i.e it cannot change. Once a transaction is executed, it stays there forever. Let’s take an example of money, let’s say we are using blockchain to handle money, so every time you send someone money or receive it, it creates a transaction which can be seen at your address. Everything is stored as a record and everyone can see the transaction history and can see some basic details which got saved in the blockchain. Now since a lot of changes do happen on blockchains continuously these transactions are grouped into bundles of records called blocks and these blocks are chained together to form (guess what) a blockchain, that’s where the name blockchain comes from.
This blockchain forms a public ledger, it’s the final truth. It shows the current state of blockchain and the history of how it reached its current state since its start. So if you own an address on the blockchain, anyone can go and see the whole history of your address on what it did in the past to reach its current state.
Moving to the final point of view i.e computers, now we have mentioned earlier that you need to connect to a node because blockchain is a peer-to-peer connection of nodes talking/working together, these nodes are basically computers, that’s why blockchain in its whole is a group of computers working together to achieve a consensus on a public ledger.
How does blockchain work?
Now that we know the basics of what makes blockchain, I intentionally threw the sentence which might seem new to a lot of audiences “Group of computers working together to achieve a consensus”. Let’s write down what we know, we know that blockchain is a decentralized peer-to-peer network which stores some information and maintains a state which is considered the holy grail of everything that has happened till now on the blockchain, but there must be some questions around this right?
How does a node know which one is the right state when every node has a copy of data? How are they handling any discrepancies? If some node did something and some nodes did another how are those things being handled? So how do different nodes all reach an agreement that this is the correct state (reaching consensus)?
This problem is very similar to Byzantine Generals’ Problem which describes the difficulty decentralized parties have in arriving at a consensus without relying on a trusted central party. The problem goes something like this let’s say 6 Generals are trying to attack from different sides of a town and are deciding on whether to attack or not. The only way one General can talk to another is via horse messenger, all Generals need to reach a consensus on whether to attack the city or not. Now if all Generals agree and attack together they will win but if only a few of them attack they are going to be decimated in the battle. Now from the Generals’ point of view, they are in conflict about whether to attack or back off to live another day. Also to keep his army alive General may lie to another General or even a horse messenger can lie or might get killed on their way to another General. How do you reach coordination or reach communication which is just perfect and works in a trustless way?
Before Bitcoin, this problem was considered perhaps impossible to solve. Computer scientists declared in 1982 that the generals’ problem can at most be reduced to a “commander and lieutenant” problem, in which all lieutenants must act by the commander’s orders, as long as they are loyal. They have shown that the problem can only have a solution if more than two-thirds of the generals are loyal.
Consensus mechanism can differ from chain to chain, for example, Ethereum currently used Proof of Work as a consensus mechanism, but will soon switch to the Proof of Stake mechanism. There are pros and cons to this, but we will study how Proof of Work works in Ethereum in the next section.
Consensus in Ethereum?
Every chain can have a different mechanism to reach a consensus. Since we have already described the problem that needs to be solved above, we are going to be ready about how Ethereum solves this via Proof of Work currently.
Every time you create a transaction on Ethereum you pay a small payment in addition to the amount of ETH you want to send to make a transaction happen. Let’s say I want to send 1 ETH to some address, I will be making a transaction of 1 ETH + a small transaction fee to make a transaction happen. To make this happen, I submit my transaction to the network and the network creates a puzzle for miners to solve and miners compete to solve this puzzle as fast as they can. Miners solve this puzzle by creating a bunch of guesses and each of these guesses gets run through a hashing function each of these guesses gets compared to the original puzzle solution and the miner which guesses it first wins and is rewarded with the fee that I sent with my transaction and it gets included in the blockchain. Whenever it gets added to the blockchain, my account gets updated (my ETH amount gets deducted) along with the account where I sent ETH (ETH amount gets incremented).
You must be wondering when everything is controlled by computers, why is it not possible to temper with the data that is stored on the blockchain? Since every node can access it, store it and has a copy of all the data that blockchain has, why can’t just one computer temper with all the data there is on the blockchain?
In order to change or temper with balance, you will have to change all the transaction that has happened in past, since your current state of balance is a result of all the transactions that has happened in the past. If you’re going to change one transaction, you will have to change every transaction that happened in past which results in a “changed transaction” and all the subsequent transactions on the blockchain, which would take incredibly powerful computation resources to do it and it’s nearly impossible. If you ever be able to do it, you will have to recompute the block or transaction that occurred and then recompute every other subsequent computation to catch up with the speed of blockchain and it gets more and more complex with every transaction that gets added. This is also called a 51% attack, it’s called 51% because you will need to control 51% of the resource’s computation power to temper with data.
Yeah, I know you are all tired at this point of consuming the information and getting your head around this new tech, trust me it took me a lot of time to get around and properly understand how beautiful each piece of blockchain works and how incredible thought is being given to each incentive that’s being placed. It’s a beautiful tech, you might hate it but you can’t hate the thought or tech behind it.
There are more concepts of how wallet creation takes place and how everything works not from a theoretical point of view but from a cryptography point of view which makes this network the most secure platform we developed yet. I will write more on this in some upcoming posts, do follow me to stay updated with all the latest articles.
New to trading? Try crypto trading bots or copy trading