How Does Blockchain Technology Work?
On the internet, as we know it, all services are located on centralized servers and are fully controlled by the companies that own them. If you want to interact with a service or any unfamiliar users in its ecosystem, you need to make sure you trust them, which is often hard.
Blockchain technology changes these principles. Blockchain is a distributed database and a data exchange protocol that is run by a global network of users rather than a centralized authority. Anyone who satisfies the conditions of the protocol can update it, so the parties interacting through this protocol don’t have to trust each other — trust in the particular blockchain is enough.
The first real-world implementation of blockchain technology was Bitcoin. Today, cryptocurrency is still its main use case, but there are also many others. Each cryptocurrency runs on its own blockchain; some cryptocurrencies run on the blockchains of other cryptos.
Why is blockchain considered one of the main technological breakthroughs of the XXI century?
When pseudonymous Satoshi Nakamoto was creating Bitcoin, he had two main things in mind. First, he criticized traditional finance for taking full control over people’s money, whereas blockchain returned this control to them. Second, Nakamoto roasted financial authorities for reckless money printing and boosting inflation. To address this issue, he implemented a scarcity mechanism in Bitcoin: only 21 million coins will ever be mined, and while the demand in BTC continues growing, so will its price.
Here are the other core characteristics of blockchain that make it a revolutionary invention:
- It’s a distributed database, meaning that all the members of the network simultaneously hold the same database and update it in real-time. Instead of a central authority, there is a consensus algorithm that ensures the agreement of all nodes regarding the updates to the database and the protocol. This means that no single company, bank, or government can alter what is happening in the blockchain — it’s impossible to freeze any account or withhold a transaction.
- Blockchain is transparent. The database that the nodes hold is open to everyone through block explorers. If you’ve sent your money to someone, you can prove this using the public data from the ledger, and they won’t have any reason not to believe you.
- Blockchain is immutable. Whatever is written in the blockchain, it cannot be altered or forged retroactively. This fact raises trust in this technology.
How does blockchain work?
Every several minutes, Bitcoin holders send a pack of transactions to each other. These transactions are put together in units called blocks and are validated by miners. To do this, they solve complex mathematical problems, which require huge computing power.
The first miner to solve the problem shows the Bitcoin network their Proof of Work that demonstrates they’ve found an optimal solution for the block. If the network agrees, the miner gets the right to add this block to the database and receives the mining reward (currently, 6.25 BTC for a block). This block will forever stay in this database and will never be altered. The database looks like a chain of these blocks — the blockchain.
We mentioned a mathematical problem that miners solve to validate blocks. This problem is called hashing, and it is performed using a hash function.
A hash function is a mathematical operation that transforms input information of any size into a fixed number of characters, which looks like an array of letters and numbers. Bitcoin leverages the SHA-256 function. Every input in it can be transformed into a unique combination of 64 letters and numbers; minimal changes in the input follow with the complete change of the output. You can test how SHA-256 works online — for example, here.
Here’s what hash we will get after hashing the word “Bitcoin”:
But here’s what we’ll get if we hash “bitcoin”:
Hashing any amount of data is a very fast process (as you can make sure using the link provided). Whenever you send a transaction, your wallet will instantly display you the transaction hash — a unique identifier that allows you to track the transaction in a block explorer.
But why is it necessary to hash blocks of transactions, and why is it so difficult?
When new transactions are sent in the Bitcoin network, miners pick them up and consecutively hash them several times. As a result, we get one hash for all transactions in a block, and it’s called the Merkle root hash (and the whole structure is called the Merkle tree):
Merkle root is one of the three main block components. Two others are the hash of the previous block and the nonce — a random number (we will explain what it serves for below). By hashing these three pieces of data, we easily get the hash of the block.
The difficulty in mining is that this hash has to correspond to one criterion — in the output, there should be several zeros at the beginning of the string. Here’s what block 700367 hash looks like (mined on September 13, 2021):
To get such a hash, you need to vary the nonce multiple times because you can’t guess in advance that nonce will correspond to the needed hash. And you have to do it so many times that people buy special hardware (GPUs and ASICs) to gain an advantage in computing it as fast as possible.
Why is this so important?
- The more zeros have to be at the beginning of the hash, the more difficult it is to find such a hash. Mining (hashing) difficulty exists so that it wouldn’t be too easy to mine a block. If anyone could do it, malicious actors with very few resources could add any wrong information to the blockchain, whereas with high mining difficulty, they’d have to put in billions of dollars to achieve this.
- As we already mentioned, every block contains a hash of the previous block. If malicious actors want to alter a certain block, they will have to change all the subsequent blocks (because if you change one block’s hash, all the subsequent blocks become invalid). This would also require the concentration of huge computing resources.
Now, let’s consider two main types of blockchains — public and private ones.
Public blockchains — permissionless ledgers for all
Public blockchains are the networks of Bitcoin and Ethereum, for example. Anyone can join them and become a validator or miner (however, for some of the largest cryptos, you’d need huge investments to start). To become a validating node, you need to buy special hardware, install software, and download the full version of a given coin’s blockchain. No permissions are needed for mining — that’s why public chains are called permissionless.
A true boom of cryptocurrency started in 2015 when Ethereum was invented with the purpose to enlarge the blockchain’s functionality. The platform enabled smart contracts — contracts in which all conditions are written in code and if met by two parties, get executed without any further human intervention. Hundreds of developers flooded into Ethereum and began building decentralized (blockchain-based) applications (dApps) for lending and borrowing, games, and collectibles, which provoked the first large crypto boom in 2017.
Private blockchains — permissioned enterprise networks
Not anyone can join private blockchains — the participants need to be approved by a central authority, which makes such networks permissioned. They are mostly used by businesses.
Private blockchains have drastically enlarged the range of blockchain use cases. They don’t usually power cryptocurrencies — rather, they are used to prove the authenticity of items, record ownership rights, and manage supply chains.
Although these blockchains are private, they are still decentralized protocols for data storage and exchange. Let’s consider an example: a chain store wants to make sure that it buys fresh fish. It opens a supply chain that is joined by the fishery. The fishery adds to this ledger the data about the time and conditions in which the fish was caught; a logistics company will inform on its delivery status; the shop will verify all this info and put labels on the packages so that buyers could check the freshness of the fish via a QR code.
All fair parties have an interest in working transparently, and that’s why private blockchains are beneficial for everyone. With their help, companies can track the authenticity of gemstones, check different items’ ownership, and some governments even run elections.
The revolution of blockchain: the main outcomes and perspectives
The concept of blockchain was proposed long before cryptocurrencies, but its first implementation was Bitcoin. Since then, within just 12 years, its scope of application has significantly expanded. Decentralized finance and NFTs, blockchain-based games, supply chains, and digital IDs emerged.
Blockchain changes fundamentally the very way people cooperate. It gives people more control over their funds and allows for near-instant cross-border payments free from third parties. But even more importantly, blockchain is not governed by central authorities, and no one can stop transactions or change their record at their will. Moreover, one doesn’t need any permission to build dApps, offering decentralized solutions for a wide range of cases.
Permissioned blockchains have a big future, too. They are the same as transparent and immutable, which is why corporations and their alliances can become more open and gain more trust. The companies don’t need to spend millions on audits anymore. And by setting such a standard of openness, blockchain can eliminate out of competition the services that are not ready to offer such transparency. It seems that this is a win-win situation for all.
All things described above have only happened in 12 years. If in 2009, anyone said that millions of people would use bank-free loans and free instant remittances, that would have sounded impossible. That’s why it’s hard to imagine what blockchain will offer us in the next decade. However, we may be sure this will be something special.