Blockchain explained: How does Blockchain Work?

Learn how exactly Blockchains work to understand how cryptocurrencies securely store user transactions.
blockchain network illustration

What is a Blockchain?

A blockchain is a distributed database that stores data in a highly secure and transparent manner, preventing it from being changed in the future.

Blockchains were invented to fully remove trust in single individuals, companies, or governments when storing and transferring any sort of data.

With a blockchain, even strangers can anonymously transact money or other assets with high assurance that everything runs by the rules they previously defined.

This is because as opposed to normal databases which are controlled by single parties, blockchains are stored, updated, and guarded by many different computers of volunteers mostly spread all around the world.

Who invented Blockchain?

The anonymous inventor of the cryptocurrency Bitcoin named Satoshi Nakamoto was the first to publicly showcase the power of blockchain in 2009 by creating Bitcoin, a digital currency that is fully independent of single companies or governments and extremely secure.

Although Blockchain technology was popularized by Bitcoin, the concept of a decentralized ledger was first introduced by researchers Stuart Haber and W. Scott Stornetta in their 1991 paper titled "How to Time-Stamp a Digital Document".

Today, blockchains are the basis of all cryptocurrencies, which use this type of database to securely and transparently process and store user transactions without having to trust each other or worry that a transaction may be changed or reverted in the future.

Benefits of Blockchain

Blockchains are said to have the potential to revolutionize the way people communicate and share data wherever a centralized trust party is involved.

By removing middlemen and storing data in a public, verifiable way, blockchains are transparent, secure from hacks, and extremely cheap in usage compared to many traditional centralized systems.

Decentralization

In centralized systems as known today, privileged individuals or groups decide over major decisions with great impact on others. For example, the owners of social media platforms can arbitrarily censor users and central banks alone decide over all traditional currencies on earth.

Blockchains on the other hand operate on peer-to-peer networks with hundreds or thousands of different participants that all have equal power, allowing the network to govern itself without the interference of governments, companies, or single developers.

Decentralized vs Centralized
Decentralized vs Centralized

Users of blockchains directly transact with one another, and the opinions of all participants regarding the rules of the network are equally important.

This makes blockchains create fair, secure, and practically unstoppable networks that are accessible to anyone with an internet connection and are mostly governed only by normal people: "From the people, for the people".

High Security

Because the blockchain is not stored in a single place but distributed on many so-called nodes in different locations around the world, popular blockchains are highly secure from attacks that could make users lose their assets.

A blockchain with many participants is almost impossible to hack, whereas traditional centralized applications usually have one single server or database that could be compromised.

Also, by using asymmetric cryptography, Blockchains define strict rules for sending and receiving transactions that prevent malicious users from sending more money than they own, or accessing someone else's assets. Hence, you can be sure that you are the true owner of your assets on a blockchain and that no one can take them away from you.

This makes many blockchains like Bitcoin extremely secure - perhaps even more secure than centralized servers and databases of companies such as banks.

Transparency

Because blockchains publicly store every single transaction, everyone can verify that every transaction in the entire history of a blockchain plays by the rules of the network.

Centralized entities like companies or central banks on the other hand can retain or falsely report internal information that leaves the public unaware of their internal processes.

On blockchains, the participants decide and actively enforce the rules and always know exactly what is going on in the network, without having to trust certain individuals or groups of individuals to check and report back to them.

Low Transaction Cost

Because Blockchains fully solve the problem of trust in digital communication, users can directly send and receive any assets like money without the need for centralized trustees such as PayPal, Visa, Western Union, and co.

This results in blockchains being extremely cost-efficient, allowing users to send assets like money around the world in near-instant time for barely any fees.

In centralized banking systems, on the other hand, sending money around the globe not only requires very high service fees but also takes at least a few business days.

How does blockchain work?

Blockchains work on decentralized peer-to-peer networks, meaning that users directly transact with each other under strictly defined rules, without relying on any third parties.

Public- and Private Key

When using a blockchain, users do not register any account nor do they share any private information with anyone.

Instead, all users of a blockchain generate a cryptographic key pair that consists of a public- and private key that represents their identity.

📫 A public key in a blockchain works like a receiving address, similar to an email address. In the example of Bitcoin, you can share your public key with others to receive bitcoins from them.

🔐 A private key in a blockchain is like a password to the corresponding public key, just like your email password gives you access to all messages sent to the corresponding email address. You can use this private key to create so-called digital signatures, proving to the network that you are indeed the owner of the assets sent to the public key, allowing you to access those assets.

By using this so-called asymmetric cryptography instead of managed accounts, blockchains purely rely on mathematics for sending and receiving assets, which removes the necessity for centralized payment providers.

For example: If Alice wants to send Bob assets on a blockchain, Alice unlocks her assets with the help of her private key and locks them with the public key that Bob has shared with her. The internal cryptography guarantees that only Bob will have access to those funds with the help of his private key.

Such a transfer of assets on a blockchain is called a transaction, and all transactions are forever stored on a blockchain.

How does a blockchain store transactions?

Blockchains store all ever-performed user transactions in the form of blocks that get added to the blockchain one by one in regular intervals.

The special feature of blockchains is that each block not only stores its own transactions but also a unique identifier - the block hash - of its previous block.

A block hash is a digital fingerprint that uniquely identifies every single block in the blockchain. If a block or any of its inner transactions would change even just slightly, its resulting block hash would change completely.

Blockchain - a chain of blocks linked with hashes
Blockchain - a Chain of Blocks linked with Hashes

Because every block in a blockchain stores the hash value of its previous block, its own block hash is partially generated from the hash of the previous block, which - figuratively speaking - creates a chain of blocks. Therefore the name 'Blockchain'.

Why is Blockchain secure?

Because every block stores the unique identifier - the hash - of its previous block, blocks in a blockchain are so tightly coupled, that changing a single transaction inside any block would not only change its own block hash, but also cause a chain reaction of changed block hashes of the entire further blockchain.

Since such a change in block hashes could easily be detected, all participants actively guarding the blockchain would immediately reject such manipulation and never reflect it in their local copy of the blockchain, making the blockchain highly secure.

a blockchain cannot be manipulated: changing one block causes a chain reaction of invalid block hashes
Why a Blockchain cannot be manipulated

In practice, this means that transactions in blockchains are graved in stone and irreversible, as any manipulation would instantly result in invalid block hashes that would be detected and rejected by all nodes of a blockchain.

Distributed Ledger

By securely storing all transactions, the blockchain acts as a distributed ledger that is used as a single source of truth when determining which users own which assets at what time.

Whenever users perform transactions on a blockchain, old transactions are never removed. Instead, the new transaction gets added to the blockchain inside a new block.

For example: if Alice owns 1 bitcoin, and sends her 1 bitcoin to Bob, who in return sends it back to Alice, there will be two transactions added to the blockchain, even though the end result would be the same if the two transactions never happened.

A blockchain's role as a distributed ledger ensures that no transaction ever gets lost or overwritten, making blockchains perfect for keeping track of transfers of ownership.

Therefore, whenever a user tries to send assets on a blockchain, all participants can quickly prove whether the user truly owns those assets or not by scanning the blockchain from its very first transaction to the very latest.

Blockchain Nodes

The nodes of a blockchain are computers that store and actively update the entire history of the blockchain, which makes the blockchain a highly-replicated and decentralized database.

In most blockchain use cases like cryptocurrencies, there are thousands of globally distributed blockchain nodes run by volunteers.

Bitcoin Blockchain Nodes Distribution
Bitcoin Blockchain Nodes Distribution - Source: bitnodes.io

Besides storing the entire blockchain, nodes also decide which new transactions are valid and eventually get added to the blockchain and which aren't, making them gatekeepers of blockchains.

Nodes play a crucial role in the security of a blockchain, as they define the rules of the blockchain and actively monitor the activity on the blockchain to ensure everything runs by those rules.

For example: If a user tries to send more money than he owns or steals the assets of another user, blockchain nodes detect this fraud and reject the transaction, as it would break the blockchain rules that all nodes previously agreed upon. Such a malicious transaction would never get added to the blockchain.

Blockchain Consensus Mechanism

The consensus mechanism of a blockchain defines strict conditions that every block of transactions must meet in order to be added to the blockchain.

There are two popular consensus mechanisms that are most frequently seen in blockchains:

Proof of Work: The consensus mechanism of the Bitcoin blockchain requires the so-called Bitcoin miners to spend a lot of energy in order to add their new blocks to the Bitcoin blockchain.

💰 Proof of Stake: The consensus mechanism of the Ethereum blockchain requires block creators to lock up a high amount of money to add new blocks to the Ethereum blockchain.

Because consensus mechanisms require cost for creating new blocks for the blockchain, they ensure that the vast majority of block creators will follow the rules of the blockchain, as breaking the rules by creating malicious blocks would result in the block being rejected, and cost associated with the consensus mechanism being wasted.

If there were no consensus mechanisms, any user could add so many random blocks so quickly to the blockchain without any cost, that the blockchain could be easily manipulated and nodes wouldn't be able to keep up with updating their local copies anymore, causing the blockchain to fully collapse.

Because consensus mechanisms require users of blockchains to commit costs - in the case of Bitcoin: electricity - to add blocks to the blockchain, the blockchain can grow steadily and be secure from spam and so-called 51% attacks.

If an attacker would try to alter the blockchain and, for example, revert blocks, he would need to re-create a portion of the blockchain with new valid blocks, and because all blocks have to meet the expensive requirements of the blockchains' consensus mechanism, the attacker would have to commit a very high amount of money to successfully attack a big blockchain.

Hence, consensus mechanisms make blockchains secure by making it extremely expensive for one malicious individual or a small group of individuals to spam a blockchain with new blocks or change/revert past blocks.

Use-cases of blockchain

Because blockchains are perfect for securely and transparently keeping track of ownership and transfer of assets, blockchains are often used as public ledgers for transferring cryptocurrencies (see Bitcoin, Ethereum), including tokens that represent ownership of real-world assets like metals, stocks, or even real estate (see NFTs or tokens like PAX Gold).

Still, blockchains are not limited to cryptocurrencies - they have endless use cases such as securely storing digital identities (see dock.io) or documenting supply chains (see Vechain) without the ability for future manipulation.

Also, because blockchains are immutable, meaning their data cannot ever be changed, blockchains are also very practical databases for storing important data distributed across the world (see Filecoin).