What is Bitcoin mining? How does it work?

Bitcoin mining is the process by which Bitcoin transactions are validated digitally on the Bitcoin network and added to the blockchain ledger. It is done by solving complex cryptographic hash puzzles.

What is Bitcoin mining? How does it work?

Bitcoin mining is the process by which Bitcoin transactions are validated digitally on the Bitcoin network and added to the blockchain ledger. It is done by solving complex cryptographic hash puzzles to verify blocks of transactions that are updated on the decentralized blockchain ledger. Solving these puzzles requires powerful computing power and sophisticated equipment. In return, miners are rewarded with Bitcoin, which is then released into circulation hence the name Bitcoin mining.

In order to validate and add new transactions to the blockchain, miners must compete with each other using specialized computing equipment. They use their equipment to generate fixed-length codes known as “hashes” (see below.) In order to discover the next block, miners must generate a hash that has an equal or higher number of zeros in front of it than the “target hash.”

The target hash is a 64-digit hexadecimal code (comprising numbers 0-9 and letters A-F) all miners are trying to get below in order to discover the next block.

As a starting point, all miners take the data from the previous block, known as the “block header”– which contains things like a timestamp of the block, the hash of the previous block data, and an empty space known as a “cryptographic nonce.” Most of the data in the block header is fixed, meaning it cannot be changed, apart from the nonce. A nonce means “a number only used once” and is the part of the previous block header that miners are allowed to tweak. Remember, just changing a single bit of the input produces a totally different hash.

The tricky part is, hashes are generated completely at random, meaning it’s impossible for miners to know what the hashes will be before they generate them. So it’s simply a case of trial and error until someone finds the right nonce value – known as the “golden nonce.”

This is why miners have to invest in energy-intensive computers, particularly application-specific integrated circuit (ASIC) miners, that can generate trillions of hashes per second.

An easy way to think of bitcoin mining is to imagine each new block is a treasure chest with a combination lock on it. To get the free bitcoin block reward inside and win the right to add new transaction data into it (and collect the associated fees) you have to keep turning one of the number wheels on the lock (the nonce) until you crack the combination (the target hash.)

Here’s an example of what a target hash might look like:

0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4df598ee

To see just how difficult it is to generate a hash with more zeros at the front than the above target hash, try creating a winning hash yourself with this free online hash generator. Simply type anything you want in the text box provided and see if it produces a hash with more than 17 zeros at the front!

What is a hash?

A hash is a cryptographic mathematical function that converts any message or data input into a fixed-length code. Think of it as an encryption technique where messages are mathematically transposed into a sequence of numbers and letters of a fixed length.

The outputs have set lengths to make it impossible to guess the size of the input. For instance, the hash for the word “hi” would be exactly the same length as the hash of the entire text of a Harry Potter book.

These hash functions are irreversible, meaning that it’s impossible to revert the hash back to its original input. The same input will also always generate the same sequence of letters and numbers. For example, the hash of “hi” will be the same code every time. Each code generated is completely unique too, meaning it’s impossible to produce the same hash with two different inputs.

In the case of Bitcoin, the blockchain uses Secure Hash Algorithm 256 or SHA 256 to generate a 256 bit or 64 characters long output, regardless of the size of the input.

How rewarding is bitcoin mining?

For every new block added to the blockchain, the protocol – a set of rules programmed into Bitcoin – releases a fixed amount of newly minted coins to the successful miner. This block reward system doubles as the distribution mechanism for Bitcoin.

As part of the programmed measures introduced by Satoshi Nakamoto to steadily decrease the number of bitcoins released over time, the coins awarded to miners are slashed roughly every four years, or 210,000 blocks, in a process known as a “Bitcoin Halving.” In 2009, the block reward was 50 BTC. This figure was reduced to 25 BTC in 2013. The most recent halving occurred in 2020, and saw block rewards fall from 12.5 BTC to 6.25 BTC.

Note that bitcoin has a 21 million maximum supply cap, and we already have 18.9 million coins in circulation. Block rewards will no longer be distributed once 21 million BTC has been released to the market. Once this happens, miners will only be able to earn rewards in the form of bitcoin transaction fees.

Even with this combination of two revenue sources, not every miner generates profits. To make ends meet, a miner’s earnings must exceed the amount spent on electricity and the purchase and maintenance of mining rigs. Also, as mining difficulty increases, large mining operations are forced to expand or upgrade their equipment to maintain a competitive edge. For most average miners who cannot afford to invest in expensive equipment, there’s an opportunity to combine their resources with other miners around the world. Each miner agrees to share rewards according to the contributions of each miner. These networks of miners are called “mining pools.”

There are, however, some rare instances where solo miners have successfully mined blocks on their own from home.

Bitcoin mining difficulty

An important thing to know about Bitcoin is that when Satoshi Nakamoto created the protocol, they programmed in a target block discovery time of 10 minutes. This means it should take approximately 10 minutes for a miner to successfully create the winning code to discover the next block.

So how does the network ensure new blocks are discovered every 10 minutes?

The Bitcoin protocol has the ability to automatically increase or decrease the complexity of the mining process depending on how quickly or slowly blocks are being found.

Every two weeks, the Bitcoin protocol automatically adjusts the target hash to make it harder or easier for miners to find blocks. If they are taking too long (more than 10 minutes) the difficulty will adjust downward; for less than 10 minutes, it will adjust upward. More specifically, the protocol will increase or decrease the number of zeros at the front. This might not sound like much, but just adding a single zero to the target hash makes the code significantly harder to beat, and vice versa.

The 2021 crackdown on mining activities in China caused bitcoin’s network difficulty to experience its biggest drop in history. This subsequently led to remaining bitcoin miners reporting significant rises in mining revenue.

Through this system, the Bitcoin protocol is able to keep block discovery times as close to 10 minutes as it can. You can track the mining difficulty of Bitcoin here.

While actively participating in the Bitcoin network can be a highly rewarding venture, the electricity and hardware requirements often limit its profitability – particularly for miners with limited resources.

Prevention of Hacking

What if someone tries to hack the data? Blockchain, as the name implies, is a chain of blocks—let’s call the blocks A, B and C. Each block has solved a puzzle and generated a hash value of its own, which is its identifier. Now suppose a person tries to tamper with block B and change the data. The data is aggregated in the block, so if the data of the block changes, then the hash value that is the digital signature of the block will also change. It will therefore corrupt the chain after it—the blocks ahead of block B will all get delinked, because the previous hash value of block C will not remain valid.

For a hacker to make the entire blockchain valid for the block B that has been changed, he or she would have to change the hash value of all the blocks ahead of block B. This would require a huge amount of computing power and is next to impossible. With this method, blockchain is non-hackable and prevents data modification.

What Do I Need to Mine Bitcoins?

Mining must have been a lot easier in the early days of its launch. As bitcoin and the blockchain concept were relatively new, mining was left to hobbyists on a discovery path. In fact, bitcoin’s inventor Nakamoto mined the genesis block on a basic CPU. As bitcoin continues to gain wider adoption, it has also succeeded in drawing keen interest from investors, miners, and companies harnessing cryptocurrency as a mode of payment for products and services. With this, mining has become a very competitive undertaking, and the hardware and software demands for bitcoin mining are also more sophisticated.

Today, bitcoin mining requires specialized tools, including:

  • Hardware such as GPU (graphics processing unit), SSD for crypto mining, ASIC (application-specific integrated circuit), or the latest FPGA (Field Programmable Gate Array) chips. When purchasing mining hardware, it is important to consider two factors, their hash rate (performance) and electricity consumption.
  • Mining software such as ECOS, BeMine, and Kryptex Miner
  • A bitcoin wallet from which an individual performs bitcoin transactions
  • Preferred mining pool (if one chooses pool mining option instead of solo mining)
  • What Does It Take to Run a Profitable Bitcoin Mining Venture?

What Does It Take to Run a Profitable Bitcoin Mining Venture?

  • Choice of Hardware
    Bitcoin mining hardware performance is measured in terms of hash rate. Current new-generation ASIC miners produce 100 TH/s (trillion hashes per second) and cost somewhere between $8,000 - $10,000. Ordinary CPUs do not have the capacity to produce such fast hash rates.
  • Location
    Developed nations may well have an edge when it comes to location because of the low cost of power. Bitcoin is quite power-intensive. It was estimated that one bitcoin transaction requires approximately 1,544 kWh of power to complete, which is equivalent to around 53 days of normal power consumed in an average American household which translates to an average of $200 in cost for a single transaction at 13 cents per kWh.
    Thus finding the right location with lower electricity costs of less than 10 cents per kWh will help maintain a profitable bitcoin mining venture.

Risks and Limitations

To hear some people describing Bitcoin mining, you’d think that all you need to do is solve a few puzzles and you’ll be rolling in easy money. But remember, if something sounds too good to be true, then it probably is. Bitcoin has its share of limitations and risks, such as:

  • It can leave security vulnerabilities that hackers can exploit
  • There is no guarantee of success; you could wind up investing a huge amount of money in the necessary equipment and have virtually no ROI (Return on Investment).
  • It’s responsible for boosting utility and computing costs.
  • Since Bitcoin and other cryptocurrencies are volatile, even if you manage to successfully mine a respectable amount of cryptocurrency, you’ll still be underwater if the value suddenly plummets.
  • Cryptocurrency is decentralized, so there are no government regulations. Consequently, there are no legal protections.
  • Bitcoin transactions are irreversible. If you send the wrong amount or give the right amount to the wrong person, well, your options to correct things are limited.
  • And finally, regardless of the huge buzz that cryptocurrencies generate, at the end of the day, it’s not widely accepted.