Let’s start with the Blockchain basics,
What is Blockchain
Blockchain is nothing more than just a particular type of database. You know what the database is. For example, if you have used Google spreadsheets or Excel before, you have seen some simple databases.
For example, you have in Excel, you create a table, and you have two columns in it. In the first column, for example, you have the names of your classmates. In the second column, there are grades for the latest exam. This table consists of rows and columns. So that’s one type of database.
Blockchain is nothing more than a particular type of database where you have some keys and some values assigned to those keys. They’re just data stored on the Blockchain. But before we go into detail, let’s take one step backwards and go into peer-to-peer networks because Blockchain is just one use case of peer-to-peer networks, and peer-to-peer networks precede Blockchain.
For example, if you have previously downloaded a movie from a torrent site like BitTorrent, then you have used one use case of peer-to-peer network. The BitTorrent network and, Blockchain is just another use case of this particular peer-to-peer network because, in peer-to-peer networks, there are interconnected computers. They are all connected. That’s also the case for the Blockchain.
It is helpful because no central entity is operating or controlling the whole network. Most networks, for example, Bitcoin, Ethereum, and Cardano, are public blockchains, meaning that the source code is general. Anyone can see it, and anyone can participate in the network.
There also exists another type of block network, which are private, and you don’t have access to them unless you’re getting an invite. And right now, private blockchains are not a big thing yet, but We believe they will be because a lot of companies will want to use the power of the Blockchain, but they want to have all the data stored publicly. So that’s a good compromise.
Do you have a private blockchain?
There is also one term we must clear before we leap more profoundly into the Blockchain. It is how the infrastructure of these networks. All those networks are distributed, which means that all the computers in the network have duplicate files at every moment. But not all distributed networks are the same.
On the one hand, you have centralized distributed blockchains; on the other, you have decentralized blockchains. Bitcoin, in Ethereum, is all distributed but centralized blockchains networks; on the other hand, decentralized distributed networks are like, for example, the most known one and decentralized exchange like uniswap where there is no central entity, no humans are controlling the network.
We are moving more in the direction of decentralized, distributed networks.
What You Should Know About Blockchain
We can look deeper into how each block in the Blockchain is created and what it consists of Blockchain. If you imagine, the Blockchain, as the name suggests, is a chain of blocks. So there are some blocks in reality on the lowest level. There are no blocks; there are no chains. These are just abstract terms.
We use them in order so we can imagine how this works. In reality, it’s all digital; it’s all binary. There are just zeros and ones and the lowest level. But now, humans have a hard time operating with zeros and ones. So we need some higher-level concepts to grasp these concepts better. If you imagine a chain of blocks, there are some blocks in the image. You see three blocks, and they are connected.
The first one is the Genesis block. It is the only block in the Blockchain because they are all created on top of the previous one. And the first one, the Genesis block, has a hash. It’s like a fingerprint. It’s a unique identifier called Hash,
The first block only contains the Hash itself. All the blocks in the Blockchain, except for the first one, also include the Hash of the previous block. It is what holds them together. That is the glue that holds them together. So each block contains some stored data, some hash or a fingerprint or unique identifier, and a previous block hash. And this is what chains them together.
What are Hash and Hashing
Hash is like a fingerprint. A unique identifier, but in reality, is just some number in a hexadecimal system. It contains numbers but also letters. It contains numbers from zero to nine and letters from A to F, representing the numbers ten to fifteen.
The hashing is the process in which we take some input, which can be like plain text or something like that. We are on a cryptographic mathematical function, a hash function, and then we get the output, which is a hash text.
This hash number hexadecimal system is so dysfunctional it takes input like a text. And on the image again, you see the word hello in two instances. The first instance is Hello capitalized. So the first letter is uppercase. And in the second input, you see hello, precisely the same word, but it’s all lowercase.
When you are on this hash function, you get an output on top of this input, and the outcome is entirely different, even though we only changed the capitalization of one letter. So the first one, hello, is capitalized. The result starts with 1, 8, 5, F, eight, and so on.
In the second case, with hello or lowercase, it’s an entirely different output. It is the power of hashing because there are no two known collisions, meaning that there are not two different inputs that would give us the same output. It is huge.
The Second Characteristic of the Blockchain is Immutability
Immutability is a harsh word, but it just means that once data is stored on the Blockchain, you can’t change it or delete it. So it’s almost impossible Once the data is stored on the Blockchain to change, modify, or delete data. Immutability leads to security.
Before we go down this rabbit hole with the Blockchain, let’s clarify one term you will see a lot in this space. And those are Forks.
What are Forks?
We have Soft Forks and Hard Forks, but they are entirely different. You can imagine soft forks like updating your operating system. When the whole community agrees to change the software, this update is distributed across the whole network, and everyone accepts that update.
Hard Forks is something completely different. A hard fork is created when some part of the community in one particular blockchain network wants some radical changes on the other part of the community doesn’t want those changes. What happens is that from that moment on, because the source code is all public, this part of the community that wants new changes takes the code modifiers and deploys a new token, a new blockchain.
And from that moment on, the two branches live separately. So the first main branch still lives on. But on the other hand and the second branch now leaves also. And the first one still operates under the first rules, under the old rules. And the second branch operates under some different new rules.
It has happened before; for example, in Bitcoin and Bitcoin cash, this is just a hard fork over Bitcoin. And now you have an Ethereum, Ethereum Classic, which was the first. It is rare, but it happens.
What Problems Blockchain Solves
There are many big, big, big problems to ensure that invalid blocks are not added to the existing Blockchain and how to add new blocks to the chain. Let’s move to the problem.
Blockchain solves vast problems as the double-spending problem goes like this. If I have, for example, 50 coins in my wallet and I want to send you those 50 coins in that transaction time, the Blockchain needs to make sure that I cannot spend additional fifty dollars that I don’t have anymore. But in the meantime, I don’t have those 50 coins anymore.
But you still don’t have those 50 coins because the transaction is still ongoing. We have to make sure that in the meantime, I cannot spend another 50 coins that I don’t have anymore, so I cannot spend another 50 coins on some other person. So this is a double-spending problem. It is, in reality, it’s rarer. It’s hard to do a scam like that in reality, but it is a big problem.
Byzantine generals problem
The second big problem is the Byzantine general’s problem. And here, as you can see in the picture on the left side, we have a castle. It is just too easy for you to imagine these abstract ideas and concepts. So we have a castle, and we have some army generals surrounding that castle, and they want to conquer the castle.
The only way to conquer the castle is if they are coordinated, meaning they can be only successful if and only if they attack or retreat simultaneously. And now, as you can see in the second, the right side of the attack is uncoordinated, meaning they do not take the same step forward or backwards simultaneously. Then they cannot conquer the castle, and they all fail. Now we have to ensure that there are no traitors among those generals.
It is a huge problem that the Blockchain can solve. How it solves those problems is via consensus protocols or consensus algorithms. The most known consensus protocol is the proof of work, which is used extensively, and it is used in Bitcoin, for example, and also in Ethereum, at least for now, until the Layer 2 solution comes up.
Proof of Work (PoW) Consensus Protocol
Let‘s take a deeper look at the proof of work in proof of work.
There are some miners, and the miners are computers, People with computers because this has become such a huge business. There are farms of computers, centralized farms of computers that are solving hard or not complex, but they are solving math puzzles, math problems.
How its Work
They are actually via sheer brute force. They are trying to come up with a number lower than they are looking for, and they spend vast amounts of electricity doing so for all those computers. And then, once they succeed at this task, they get a reward in terms of coins.
On the other hand, they need to pay for the electricity in fiat money, for example, in euros or dollars.
So they need to convert those bitcoins into fiat money. But the current price of Bitcoin is low; they will not sell their coins because they wouldn’t even break even if they sold them. And that low price.
What they are doing is they’re controlling the market in a way, and they hold the supply. And once the supply in this circulation is low, the price starts to go up, and they go and sell their coins, increasing the supply, and then the price goes down again.
Now, let’s take a look at the Blockchain transaction process.
The first thing you do, if I want to send you one Bitcoin, what they do first is I request this is all in the back, and you don’t see that. It is to clarify how things work in the back end. So the first thing is the transaction request.
The second thing is that the block represents the transaction, so it has a hash created, and then this block is sent to all the nodes. Nodes are, again, computers in the network that validate those transactions.
They can be miners or don’t need to be miners when they are nodes. So nodes validate that transaction. It is the first time, and this is validated. We are processing what I described earlier with miners.
Then nodes receive a reward once the task is completed, and then this block is added to the existing Blockchain, then the update is distributed across the whole network, and then the transaction is complete. I don’t have that one Bitcoin anymore. And now you have that one Bitcoin.
Now let’s think again. And the transaction process from a cryptographic perspective.
You see here that Jennifer wants to send a message to David, and the message says, hello. She encrypts this message, and she has her private key and her public key. David has his private key and his public key.
Jennifer encrypted this and sent the message to David, decrypted this with the piece, and then he could see the message. But in the meantime, the message is encrypted, meaning that no one without private keys can see what the message says.
Proof of Stake (PoS) Consensus Protocol
Another consensus algorithm exists; the second consensus protocol is proof of stake. And right now, some blockchain networks already use this proof of stake. Even Ethereum is now doing some part work to go from proof work to proof of stake.
Proof of Stake
There are no miners. There are just validators. Validators stake their coins to participate in validating the sections. And more you stake, the higher the chance for you to be selected as the value of the transactions, and the catch if it’s not profitable to be a scammer because you have to put your own money in, and that money is locked for that period, you cannot access that coins in the meantime.
And then the reward you get for validating transactions is always lower than the amount you stake. If you want to scam the system, you will lose more money than you could. It is the security feature of the proof of stake consensus protocol.
Let’s clarify what intelligent contracts on Blockchain
Most contracts are on the Ethereum network, at least for now. Smart contracts are nothing more than just simple programs that automate transactions. They are just a few lines of code that human programmers wrote to automate some transactions.
You can imagine it’s like Vending machine, and there are just some drinks in it, and you put some coins there, and you select one drink, and you get. You put enough money in, like that thing, and get the item. That’s all it is. And with smart contracts is the same.
Those are just some computer programs, small actually, that ultimate transaction. And this is the real power because no intermediary is needed anymore.