How the Blockchain System Works
Blockchain technology is probably the best invention since the internet itself. It allows value exchange without the need for trust or central authority.
Imagine you and I bet $50 on tomorrow’s weather in San Francisco. I bet it will be sunny, you that it will rain. Today we have three options to manage this transaction:
- We can trust each other. Rainy or sunny, the loser will give $50 to the winner. If we are friends, this could be a good way of managing it. However, friends or strangers, one can easily not pay the other.
- We can turn the bet into a contract. With a contract in place both parties will be more prone to pay. However, should either of the two decide not to pay, the winner will have to pay additional money to cover legal expenses and the court case might take a long time.
- We can involve a neutral third party. Each of us gives $50 to a third party, who will give the total amount to the winner. But hey, she could also run away with all our money.
Neither trust nor contract is an optimal solution: We can’t trust strangers, and enforcing a contract requires time and money.
Blockchain technology offers us a fourth option – secure, quick, and cheap.
We can write a few lines of code (a smart contract) running on the blockchain, to which both of us send $50. This program holds the money, checks tomorrow’s weather automatically on several data sources, and sends the total to the winner. The logic is transparent, cannot be changed once deployed, and no one controls it. This might be too much for a $50 bet, but imagine selling a house or a company.
The Basics of Bitcoin
The most known and discussed application of blockchain technology is Bitcoin, a digital currency that can be used to exchange products and services.
One bitcoin is a single unit of the Bitcoin (BTC) digital currency. Like a dollar, bitcoin only has value because people believe in it and are willing to accept it.
To keep track of how much bitcoin each person owns, the blockchain uses a ledger, a digital file that records all bitcoin transactions. Unlike traditional banks, this ledger is:
- Not stored on a central server
- Distributed across a global network of computers (nodes)
- Continuously updated and synchronized
When David sends bitcoins to Sandra, he broadcasts a message to the network. The message says that his balance should decrease by 5 BTC and Sandra’s should increase by 5 BTC. Each node receives the message and updates its own copy of the ledger.
Transaction Request Message Simplified
- In a bank, only you and the bank see your transactions.
- On the blockchain, everyone can view all transactions.
- If something goes wrong, there’s no support line to call.
But that’s the beauty of blockchain: no trust is required. Security and reliability come from math and code.
Digital Signature Transaction Encryption Simplified
To use the blockchain, you need a wallet, a program that stores your private and public keys and lets you send/receive bitcoins.
Every wallet is protected using cryptography:
- Public Key: Shareable
- Private Key: Secret
Only someone with the private key can authorize a transaction from a wallet. When David wants to send bitcoins, he encrypts the message with his private key. The network uses his public key to verify the message.
This process generates a digital signature, unique for each transaction. Even the slightest change in the message will make the signature invalid. This ensures authenticity and prevents tampering.
Tracking Your Wallet Balance
Unlike banks, the blockchain doesn’t store balances. It stores every transaction.
To check a balance, the wallet software scans all previous transactions associated with your wallet’s public key and calculates your unspent bitcoins.
Blockchain Ledger
Every transaction is based on input references – links to previous transactions.
When Mary wants to send 10 BTC to John, her wallet includes references (inputs) to previous incoming transactions totaling at least 10 BTC.
Network nodes:
- Verify those transactions were valid
- Ensure the inputs haven’t been used before
Once used, those inputs become invalid for future transactions. This is how the system prevents double spending.
Blockchain Transaction Request Structure
This process is automatic in the wallet software. Each transaction uses your wallet’s public key and references previous transactions.
The system keeps a list of unspent transaction outputs (UTXOs) to speed things up. As long as your wallet has unspent inputs, you can make new transactions.
All Bitcoin network code is open-source. Anyone with a computer and internet can use it.
But be careful: Mistakes in transaction code can lead to permanent loss of funds. There’s no undo button, customer support, or password reset.
But Is It Really Safe? And Why Is It Called Blockchain?
The bitcoin network allows users to interact anonymously. You can:
- Use multiple wallets
- Keep your identity hidden
- Avoid linking transactions
But if you reuse the same public key, people can trace your transaction history.
The total number of possible bitcoin addresses is 2¹⁶⁰
, an enormous number that keeps the network secure.
The Blockchain Sequence-Structure Simplified
How does the network determine which transaction happened first? Timestamps can be faked.
Instead, the network uses blocks to organize transactions.
Each block:
- Contains a set of transactions
- Includes a reference to the previous block
- Is linked chronologically to the last block
This forms a chain of blocks – hence the name Blockchain.
End of Chain Ambiguity Logic
Sometimes two blocks are solved at the same time. When this happens:
- Each node temporarily accepts the first one it receives
- When a new block is added, nodes choose the longest chain as the correct one
- Any block not part of the longest chain becomes invalid
This ensures that everyone eventually agrees on a single version of truth.
Mary’s Double-Spending Attack
Let’s say Mary sends money to John. John ships the product. Then Mary builds a longer chain with a reverse transaction. If her chain wins, John loses both the product and the payment.
But here’s the catch: Solving a block is hard. Solving two or more in a row is extremely unlikely. Mary would need to control at least 50% of the network’s total computing power to even have a chance – and still, success isn’t guaranteed.
This is why the Bitcoin network is considered secure.
Bitcoin Mining
To process transactions, someone has to:
- Run blockchain software
- Solve complex math problems
- Propose new blocks to add to the chain
This process is called mining.
Miners are rewarded with new bitcoins for solving blocks. These rewards:
- Encourage people to run nodes
- Keep the network decentralized and secure
Mining is hard work. On average, it would take one year for a regular computer to solve a block. So miners form mining pools, sharing their computing power and splitting the reward.