Bitcoin Mining Basics: A Comprehensive Guide for Beginners

Omoyemi Arigbanla
4 min readFeb 22, 2024

--

Photo by Michael Förtsch on Unsplash

Mining is the process of adding new blocks of transactions onto the blockchain. It involves the validation of transactions, the addition of new blocks to the blockchain, and the creation of new units of the cryptocurrency. This new unit of bitcoin is an incentive given to the miners for taking part in the expensive task of mining and it is known as a coinbase transaction. Miners compete to solve a complex mathematical puzzle, and the first miner to find the solution gets to add a new block of transactions to the blockchain.
The coinbase transaction is a key mechanism for distributing new coins and rewarding miners. It is always the first transaction included in each block. This makes it easily identifiable and distinguishes it from regular user transactions.

How Does Bitcoin Mining Work?

When users send Bitcoin, they broadcast the transaction to the network. These transactions are stored in a temporary storage for transactions received by a node called the mempool. Miners collect unconfirmed transactions from the mempool and assemble them into a temporary block known as a candidate block. if the mining process is successful, this candidate block will be included in the blockchain and sent to every other node.
The candidate block contains a block header which is like the metadata of the block. The block header is made up of the following:

  • Previous Block Hash: The previous block hash links the current block to the previous one in the chain. This 32-byte field creates a chain of blocks, linking them together in chronological order. The previous block hash is crucial for maintaining the integrity and continuity of the blockchain.
  • Merkle Root: The Merkle root is a 32-byte hash summary representing all transactions within the block. It links all the transactions in the block together via the Merkle root, ensuring the integrity and immutability of the transaction data.
  • Timestamp: The time field in the block header denotes the Unix time at which the block header is being hashed. This timestamp is used during the mining process and is essential for verifying the authenticity and chronological order of the blocks.
  • Nonce: The nonce field serves as a counter used for the proof-of-work algorithm. The nonce is the value that miners can alter to create different permutations and generate a correct hash in the sequence.
  • Version: Identifies the version of the blockchain protocol used by the block. It is a 4-byte integer that allows for protocol upgrade support and readiness signaling. This field enables the implementation of new features and improvements to the Bitcoin protocol over time.
  • Bits: A shortened version of the Target. It informs miners about the level of difficulty required for a valid hash. Miners use this encoded target difficulty to determine what the network will accept as valid, guiding their mining efforts.
Figure 1: Structure of a block (Source: Acervolima.com — Online)

This block header is then hashed using the SHA-256 hashing algorithm with the hope that the corresponding value is below the current target. The target is a 256-bit number (extremely large) that all Bitcoin clients share. The target adjusts every 2016 block (roughly two weeks) to try and ensure that blocks are mined once every 10 minutes on average.
The SHA-256 hash of a block’s header must be lower than or equal to the current target for the block to be accepted by the network. The lower the target, the more difficult it is to generate a block. On average, blocks were designed to be mined once every 10 minutes. If blocks during the two weeks were being mined faster than every 10 minutes, the target would adjust downwards to make it more difficult to get below the target for the next period of blocks.
If the hash isn't below the target, the nonce value is adjusted till it is. Once this is achieved, the block is broadcast to other miners in the network. These miners verify the block and its transactions by re-calculating the hash and ensuring it matches the claimed value.
If the block is valid, it is added to the blockchain, and the transactions within it are considered confirmed. The miner who successfully mined that block is entitled to a block reward and can claim this reward from the coinbase transaction when the block becomes 100 blocks deep in the longest chain. The reason for this is to prevent a miner from spending a block reward from a block that may later be regarded as being a stale block after a fork in the blockchain.
A block reward is the combination of newly generated coins and transaction fees which is a crucial incentive for miners to continue solving complex mathematical problems and validating transactions. Bitcoin has a planned limit of 21 million coins which is expected to happen around the year 2140. At this stage, miners will no longer get new coins for mining but will solely be rewarded with fees for processing transactions. These fees will ensure that miners still have the incentive to mine and keep the network going.

Figure 2: Image showing a block with the coinbase transaction and corresponding transactions with their respective transaction fees ( Source: Anatomy and Lifecycle of a Bitcoin Transaction, page 733)

In conclusion, mining is a continual process that helps introduce new bitcoins into the network while ensuring the security, integrity, and decentralization of the Bitcoin network and incentivizing miners with rewards for their efforts.

References

--

--

Omoyemi Arigbanla
Omoyemi Arigbanla

Written by Omoyemi Arigbanla

Tech enthusiast | Petroleum engineer and software developer | Philosopher | Traveler | Writer.