Why does Bitcoin Mining Exist? How does it work?

Published in
6 min readAug 2, 2021

What is a nonce and how is the SHA-256 algorithm connected to it?

Photo by Jeremy Zero on Unsplash

Let’s start off with some basic background knowledge.

What is Cryptocurrency

A digital currency that uses cryptographic protocols. A form of digital medium of exchange to facilitate transactions. Cryptocurrency is based on blockchain technology. It is a borderless payment system with irreversible transactions.

  • Borderless: Sending money overseas is expensive and takes a while.
  • Irreversible transactions: transactions cannot be canceled or reversed. I’ll draw an example of credit card transactions. In case of suspected fraud, we can inform our credit-issued bank regarding the transaction. The bank can then flag and cancel the transaction even if you have performed the transaction. This will be outlined below when I explain the electronic payment network used by financial institutions.

What is Blockchain

Blockchain is a decentralized public ledger that holds financial transaction information. It usually includes information like:

  • When the transaction occurred (time-stamp)
  • How much is being transferred (amount of cryptocurrency)
  • Between which wallet did these transactions occur?

Once the financial data is uploaded onto the public ledger, it cannot be changed. The transaction is irreversible.

How Does Blockchain Work

We know what is blockchain. But how does it work?

Let’s say there is 2 person who wanted to transact. Person A wanted to give Person B $50.

When Person A makes a transaction, it is represented by a block. The block is uploaded to the network, to be approved. I am going to use the oldest method to verify transactions — proof of work consensus also known as mining. The network of miners competes to verify transactions. Once the financial transaction is verified, the transaction completes and the block is added to the existing public ledger.

Recall the definition of blockchain? Yeah, it is the decentralized public ledger. Hence, blocks connected together — blockchain… very creative.

Why do we need to waste energy to approve transactions?

This is to prevent the double-spending problem. Double spending simply means sending the same money twice. For instance, when you have $20 cash and you spend it on a coat, you cannot spend the same money again.

Digital money like cryptocurrency has to prevent the problem of double-spending. Digital currency can be easily reproduced. It is just a number on the screen, prone to be manipulated or even hacked.

Automated Clearing House, traditional financial electronic transfer
Photo by Pickawood on Unsplash

Drawing comparison with the traditional banking system

Let’s examine how the traditional banking system prevents it. When money is transferred from one bank to another bank, it is not a direct transaction.

In the United States, money is moved through the Automated Clearing House (ACH) system. ACH network acts as a financial hub.

Our digital transactions look instantaneous, it actually takes 1–2 business days to completely settle. The trusted, third party authorizes the transaction. This means that the financial institution takes the credit risk and ensures transaction occurs. If an issue arises, the financial institution that facilitates the transaction will be liable.

In the blockchain, there is no central financial institution to bear liability in case a transaction fails. Hence, Blockchain combats this by letting their network of computers participate to verify transactions.

Cryptocurrency transactions can be completely settled within minutes. Instead of our traditional financial transaction that is settled in 1–2 business days.

The consensus algorithm syncs the network of computers. One such algorithm to verify transactions is proof of work consensus.

encryption of bitcoin and bitcoin mining system
Photo by Ewan Kennedy on Unsplash


In the initial whitepaper, Bitcoin is described as a

A Peer-to-Peer Electronic Cash System — Satoshi Nakamoto in Bitcoin Whitepaper

Bitcoin is a form of digital money that has properties of money-like goods. What is considered a money-like good?

  • Portable: Large amounts of Bitcoin can be stored in a wallet. It can be easily transacted to another user.
  • Fungible: 1 Bitcoin is equal in value to another bitcoin. For instance, $50 is equivalent to $50 no matter the identifier of the cash.
  • Scare: There will only be 21 million Bitcoins.
  • Recognizable: each individual BTC mined has a unique identified,
  • Divisible: 1 BTC can be divided into two 0.5 BTC or four 0.25 BTC. Fun fact, the smallest unit of Bitcoin is called a Satoshi.

Proof of Work Consensus

Bitcoin uses Proof of Work (PoW) consensus to verify transactions. As explained above, this is to prevent double-spend issues. PoW is inspired by Hashcash.

What is Hashcash?

It is a PoW system to limit email spam and prevent denial-of-service(DOS) attacks. It is a cryptographic protocol. Bitcoin algorithm uses the SHA-256 algorithm, originally developed by the US’s National Security Agency (NSA) in 2001. The SHA-256 encryption algorithm is also commonly used by SSL certifications on modern websites.

Why bother to understand the SHA-256 algorithm?

By understanding the SHA-256 algorithm, we can understand the inner workings of the cryptocurrency, and how it uses encryption to give us security and privacy. It also provides an understanding of bitcoin mining.

SHA-256 Encryption Algorithm

SHA-256 takes an input and produced a fixed-length output, this is called a Hash. The specific length of the hash is 32 bytes and displayed in 64 alphanumeric characters.

Encryption is essentially jumbling random characters to obfuscate the real information. Having a fixed-length output means no one can guess how long or short the input is, increasing security.

SHA-256 will always produce the same output when given the same input, this is a one-way function. It is almost impossible to decipher. SHA-256 is computationally efficient than an ordinary computer can perform its computation.

SHA-256 and PoW

In the PoW network, computers race to solve complicated math problems. How do computers even begin to solve the problem?

It starts with the data available in the block header.

What is a Block Header?

When you send a cryptocurrency the block header will contain information like a version number, timestamp, the hash used in the previous block, the nonce, and the target hash.


Short for “number used once”. Nonces are generated to modify the result of a function. This is the only value in the block header that is not predetermined. Miners compete to get the appropriate nonce value. When the nonce value plugged into the algorithm generates a hash value that is lower than or equal to the target hash, it is accepted as the solution.

Computers are bashing their heads to get a value of nonce that fits into the puzzle. The miner that successfully got the appropriate nonce value will be given the reward and the block is added to the public ledger — the blockchain.

The computer that finds the solution broadcast to the peer-to-peer network. This proves their work to other machines, other machines then compete to solve the next block. A new problem presents itself, competition between computers begins.


Cryptocurrency is made out of cryptographic protocols. Bitcoin needs mining to verify transactions to prevent double-spending.
Bitcoin uses the SHA-256 algorithm which always has a fixed-length output. This allows miners to focus on a specific target to guess — nonce.

The nonce is used to verify the transaction. Once a miner gets a nonce value that is equal to or less than the target difficulty, the solution is accepted. The block adds to the blockchain and the miner who finds the solution gets rewarded in Bitcoin.

Reformatted content. Originally published at https://comprehend.substack.com. A weekly newsletter that shares blockchain basics and blockchain projects.

If you liked my articles, why not subscribe to get notified whenever I publish?




Crypto enthusiast. Privacy and security advocate. Obsessed about productivity, self-development, and finance. Learn about crypto on comprehend.substack.com