Blockchain

How Does a Blockchain Work? | ConsenSys

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 “immutable”—the 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’ll notice us use “Bitcoin” with an uppercase B to refer to the overall blockchain and “bitcoin” with a lowercase b to refer to the Bitcoin network’s cryptocurrency.

Next, let’s 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—such as Alice’s transaction with Bob—it is grouped together in a mathematically protected “block” 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’s gone. However, it is worth noting that this benefits individuals and businesses that deal with credit card transaction, which aren’t 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 “hash.” 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 “Solution”
  • 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 ———d89sdf8sge9nxc894opl8qjroi5635h3kjhk24gd5we94

……

Solution 6517 ———088djldkh2h5h3kjhk24gdjroi5635h3kjhk24gd5we

Solution 6518 ———00088djldkh2h5h3kjhk24gdjhk24gd5h2hk24g4f4

Given the input of “Solution 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’s 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’s hash, ensuring a chronological block order. For instance, block 30’s 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 “genesis 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’t 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.

Related Articles

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker