How the Bitcoin Blockchain Works
A Spreadsheet Analogy
Imagine a blockchain as a spreadsheet. Everyone has access to the data within each individual cell and saves a copy to their personal computer. The data within the spreadsheet is shared between multiple people. However, nobody can alter an individual cell or change the existing information. In the blockchain world, we call this 鈥渋mmutable鈥濃攖he inability to change or modify something over time.聽
Now, imagine you wanted to add a new cell to the spreadsheet. This would require approval from members who have access to the spreadsheet data. Once a majority of the spreadsheet owners approve the new cell, the data would then be added to the main spreadsheet.聽
Back to Bitcoin
As an aside, you鈥檒l notice us use 鈥淏itcoin鈥 with an uppercase B to refer to the overall blockchain and 鈥渂itcoin鈥 with a lowercase b to refer to the Bitcoin network鈥檚 cryptocurrency.聽
Next, let鈥檚 apply the above concepts to further understand how the Bitcoin blockchain works. If Alice traded one bitcoin to Bob, that transaction would be recorded in the Bitcoin blockchain ledger. Viewing the ledger would show how much bitcoin was exchanged when the transaction occurred, and the corresponding bitcoin addresses of Alice and Bob that sent and received the transactions.聽
Bitcoin Miners
Once a transaction has been made, it must be verified by people called miners. When a transaction occurs鈥攕uch as Alice鈥檚 transaction with Bob鈥攊t is grouped together in a mathematically protected 鈥渂lock鈥 with other transactions that have happened in the same time frame. Miners then use computers with incredible computing power to solve the block mathematically. The first miners to solve the block and validate the transactions are rewarded with bitcoin. This is the only way that bitcoin can be created. Finally, each block is connected to the previously verified block, creating a chain of blocks, hence the name blockchain (we know, super creative).聽
One more thing that you need to understand about the blockchain is that it is immutable, which means, once the data has been added into a block, it can never (like never ever) be changed. In a practical application, once Alice trades her bitcoin and the transaction is verified, she cannot get it back or cancel the trade. It鈥檚 gone. However, it is worth noting that this benefits individuals and businesses that deal with credit card transaction, which aren鈥檛 settled until later dates. A malicious individual, using a credit card could purchase an item and then cancel the transaction leaving an individual or business with lost revenue.聽聽聽
Consensus Algorithm聽
When Alice trades her bitcoin to Bob, the transaction is represented as a block, which needs to be broadcasted to the blockchain network. The blockchain network is comprised of nodes or participants of the network that validate and relay transactions to transmit information.聽聽
All nodes are operated voluntarily and are used to verify the correct transactions on the blockchain. Nodes follow consensus rules, which are rules that are agreed upon by the community. A change in the consensus rules requires 95% of the community to approve, which makes it incredibly difficult for one group to change the Bitcoin software. Other consensus algorithms require a lower percentage to change the software protocol. Nodes relay block transactions and validations to other nodes so that the network remains updated. Nodes do not mine bitcoin. However, all miners typically run a full node to validate and relay bitcoin transactions effectively. Since both miners and non-miners execute validation and relay by operating nodes, they all participate in the consensus process.聽
Bitcoin Mining聽
Bitcoin miners verify legitimate transactions and create new bitcoin as a reward for their work.聽
A transaction is considered verified once the miner solves a cryptographic (mathematical) puzzle. Bitcoin uses a protocol called proof of work, which has a broad goal to prevent cyber attacks from any single entity or group. More specifically, Bitcoin uses the Secure Hash Algorithm 256 bit (SHA-256). Computer chips can run the SHA-256 algorithm to generate an output, which is referred to as a 鈥渉ash.鈥 Hashing, the process of creating multiple hashes, is used to solve the mathematical problem, in which the end answer is the known and expected hash value.聽
A Simplified Example聽
- To solve the problem, the hash value has to begin with three zeros: 鈥000鈥
- The input then varies every number finding a match for a 鈥淪olution鈥澛
- It takes 6,518 tries to find a value that has 鈥000鈥 in the first three digits.聽
Solution 1 鈥斺斺088djldkh2h5h3kjhk24gd5h2h5h3kjhk24gd5kh2h5h
Solution 2 鈥斺斺73485jfljroi5635h3kjhk24gd5we94ee356h2hkh2h5h
Solution 3 鈥斺斺攄89sdf8sge9nxc894opl8qjroi5635h3kjhk24gd5we94
鈥︹
Solution 6517 鈥斺斺088djldkh2h5h3kjhk24gdjroi5635h3kjhk24gd5we
Solution 6518 鈥斺斺00088djldkh2h5h3kjhk24gdjhk24gd5h2hk24g4f4
Given the input of 鈥淪olution 6518,鈥 any miner could verify that this undeniably creates a hash with three zeros in the first three digits. The first miner to solve this problem would broadcast their answer to the network and be rewarded with bitcoin. The block would then be considered verified, and it would be added to the blockchain. This puzzle is a representation of the type of puzzle a Bitcoin miner would need to solve and not a real puzzle.聽
Confirmation Difficulty
A standard Bitcoin block requires millions of hashes to solve the puzzle. In the Bitcoin blockchain, the complexity of the puzzle changes every 2,016 blocks to ensure that the average block confirmation time takes ten minutes. Therefore, it is possible for the problem to become easier to solve if confirmations are consistently taking longer than ten minutes. Although, usually the problems become more challenging to solve, which has made it very expensive and highly time intensive to confirm blocks.聽
Initially, bitcoin could be mined using consumer-grade computing chips. However, due to this increase in difficulty, bitcoin mining currently requires enormous hashing power, and the industry utilizes application-specific integrated circuit (ASIC) chips. ASICs are customized specifically for bitcoin mining, rather than general-purpose functions. These chips are also incredibly expensive, which has resulted in a select group or pool of miners that dominate the lion鈥檚 share of the bitcoin mining activity.聽
Block by Block
Another important aspect is that each block contains the solved hash from the parent or previous block. Each new block requires the parent block鈥檚 hash, ensuring a chronological block order. For instance, block 30鈥檚 hash is necessary for block 31. Block 31 cannot exist until block 30 has been verified and added to the blockchain. This guarantees that each block is connected all the way back until the first block, which is commonly referred to as the 鈥済enesis block.鈥 To change any single block would require changing every preceding block, simultaneously. Lastly, each block is immutable, which again, means that once a transaction occurs, it cannot be reversed. This further ensures that once added the blocks within the blockchain cannot be altered.聽
Supply
The supply of Bitcoin is limited to 21 million bitcoins, which is estimated to occur around the year 2140. The amount of bitcoin rewarded to miners is halved every 210,000 blocks. Therefore, the reward will continue to split until the twenty-one millionth bitcoin is created, at which point miners will only receive transaction fees.聽
Why Don鈥檛 Miners Cheat?聽
Bitcoin is deeply rooted in cryptography, computer science, economics, and various other disciplines. One of those disciplines happens to be game theory, which uses mathematical models to predict how rational players will react when given individual choices or situations. Bitcoin utilizes game theory concepts to incentivize the desired action of miners and users.