How Does Blockchain Mining Work and How to Set it Up

How Does Blockchain Mining Work and How to Set it Up

When people hear "mining," their minds conjure an image of people with hardhats digging the ground for precious metals.

But the blockchain is a digital concept, so what is blockchain mining?

Blockchain mining is a process that involves computers verifying and adding transactions to the blockchain. Mining is also responsible for introducing new cryptocurrencies into the existing supply.

Mining helps secure the validity and reliability of blockchain-based transactions. Since the blockchain is absent of centralized control, miners are crucial to maintaining the ledger and securing it against malicious activity.

This article explains what blockchain mining is and why it matters for cryptocurrency. We'll also answer the "how does blockchain mining work?" question and detail how to start blockchain mining.

Let's dig in.

What Is the Blockchain?

Understanding blockchain mining requires a good grasp of how blockchain works. If you're new to the technology, here's a crash course on blockchains:

Blockchain technology is a distributed ledger that records transactions performed on the network. This "network" is an interconnected group of computers (called nodes) that contribute to the system by checking the validity of transactions.

New transactions on the blockchain are packaged in "blocks", which are essentially files containing data. Nodes confirm these blocks and add them to the ledger.

Each block is linked to the preceding block through cryptographic protocols. This creates the semblance of a chain—hence, the term "blockchain."

How blockchain transactions are verified.png The anatomy of a blockchain transaction. Source: Euromoney.com

Why is Blockchain Mining Important?

As explained earlier, mining is the process of confirming and verifying transactions before they are added to the blockchain. But you may wonder—why do transactions need verification in the first place?

When someone initiates a transaction, nodes confirm if the person has enough in their wallet balance to fund the transaction. Say the transfer involves a non-monetary asset, like digital data, the sender must prove ownership of the asset.

Remember that cryptocurrencies transferred on the blockchain are not backed by a central authority. As such, a system is necessary to ensure that no one tries to spend the same funds twice or transfers assets they don't own.

This problem doesn't come up with physical currencies. If you spent $5 on a cookie, it's impossible to spend that same $5 on a Snickers bar.

Can you spend a counterfeit version of the five-dollar bill on another purchase? Maybe. But a simple check of the details on each bill (including the serial number and watermark) will expose the fake currency.

Cryptocurrencies are digital records existing on the blockchain. And that means any Tom, Dick, and Harry will try to copy and counterfeit them to spend them in illicit transactions.

Fortunately, Satoshi Nakamoto, creator of the first cryptocurrency (Bitcoin) had a solution to the problem of double-spending.

Called proof-of-work, this system brought a way for participants to agree on a shared history of the blockchain. This meant that no one could double-spend a bitcoin twice since nodes would cross-check the records before accepting the transaction.

Proof-of-work incentivizes nodes to verify transactions by rewarding them in cryptocurrency for each block successfully added to the chain. However, nodes (called miners) must compete to validate new transaction blocks.

Proof-of-work requires miners to dedicate intensive computing power before adding new blocks. But this is a feature, not a bug. The higher barrier to entry prevents malicious behavior since dishonest miners lose both block rewards and their initial investment (electricity).

Bitcoin isn't the only cryptocurrency to use mining. Popular PoW cryptos include Litecoin, Ethereum (before the Eth2 upgrade), ZCash, and Elon Musk's favorite, Dogecoin.

How Does Blockchain Mining Work?

When a transaction is initiated on the blockchain, it goes to the memory pool—a place for storing unconfirmed transactions. It is the responsibility of the miner validate these transactions and assemble them into blocks (candidate blocks).

While the miner has a block of valid transactions now, the candidate block itself is not valid until other nodes accept it. To validate a block and receive the reward, the miner must perform a series of computing-intensive calculations.

Finding the correct answer converts the candidate block into a valid block and gives the miner the associated block reward. Read on for a more detailed explanation of the mining process:

1. Hashing Transactions

After taking transactions from the memory pool, the miner runs each transaction through a cryptographic mechanism called a hash function. This creates the "hash", a 64-character string that serves as a "fingerprint" for on-chain data.

Hashes are collision-resistant, meaning no two inputs will produce the same output, i.e., hash. Here's an example of a hash for the term "Hashnode" generated from the Sordum SHA-256 hash generator:

c07ac5f66c417cd2e59e8be1560aafc660cffe6b14bc0287aef8e11ca87e1093

Hashes help preserve the integrity of data on the blockchain because they cannot be modified—lest the hash becomes invalid.

blockchain hash function infographic.jpg A description of cryptographic hash functions. Source: BitPanda.com

2. Creating a Root Hash

Now, back to our friendly miner. After hashing the transactions, they pair the outputs and keep hashing until they arrive at the root hash of the candidate block. This root hash is the combination of all transaction hashes and identifies the group of transactions in each block.

If a single transaction is changed, then the root hash changes, too. This is why it's impossible to alter data stored on the blockchain and get away with it.

Once they have the root hash, the miner is close to validating the candidate block. But winning that elusive block reward requires one additional task: finding the target hash.

3. Finding the Target Hash

The target hash is a numerical value that the block header must be less than or equal to before getting confirmed. Block headers are unique identifiers for each block and contain the following information:

  • The block timestamp
  • The previous block's hash
  • The root hash
  • The nonce

Miners run the hash of the previous block, the root hash, and the nonce through the hashing algorithm to find the correct hash for the candidate block. The "nonce", short for "number used only once", is a random number used to modify the output of the hashing algorithm.

Since the hash of the previous block and the root hash is fixed, the nonce is what changes during the calculations miners perform to find the target hash. So, the real work for miners is to find the magical nonce that generates the target hash.

The target hash is usually a 64-bit string that starts with several zeros. A miner must find a value that's lower than the hash or equal to it before validating the candidate block and receiving the block reward.

Graphic representation of proof of work mining.png Proof-of-work mining explained. Source: Etherplan.com

4. Broadcasting Mined Blocks

Once the miner succeeds in calculating the target hash, they can broadcast their candidate block to the chain. Once the remaining nodes confirm validate the candidate block and its hash, it becomes a valid block and is added to the blockchain.

Other miners who were unable to find the target hash will discard their candidate blocks and start competing to add the next block. This process repeats every roughly 10 minutes, which is the average time it takes to create a new block.

How to Start Mining Cryptocurrency

Many people think the only thing miners do is waste computing power on solving puzzles to earn money. Mining is necessary for securing the blockchain and protecting the integrity of transactions in the absence of a trusted intermediary.

Mining is a good way to contribute to the security of the blockchain and earn rewards for your efforts. Here are things you'll need to start your blockchain mining journey:

  • Cryptocurrency wallet
  • Blockchain mining software
  • Blockchain mining hardware

We have created an actionable guide to mining for beginners like you. It covers mining requirements in detail and factors to consider before you start mining cryptocurrency:

Create a Cryptocurrency Wallet

A wallet is an online account where you store cryptocurrencies. It also allows you to securely receive and transfer crypto anytime you want. You'll need a cryptocurrency wallet to collect the block rewards earned during mining.

While this step may seem trivial, it is more important than most people realize. Mining is a cost-intensive process, so imagine losing your rewards to a malicious actor. And there is no shortage of cyber-thieves trying to steal your hard-earned crypto.

The advice here is to get a highly secure wallet that can protect your crypto. Ideally, a wallet should have two-factor authentication to ensure no one can access it without your permission.

Some use a "cold wallet," which is offline storage for cryptocurrencies. Cold wallets are usually physical devices that you can carry around.

Because it's disconnected from the internet, a hardware wallet is theoretically secure against hackers. The downside is that losing the device means you cannot retrieve your crypto.

Here's a handy guide to help you find the best crypto wallets.

Picture showing hardware crypto wallets.jpg Picture of hardware crypto wallets. Source: Unsplash.com

Select Blockchain Mining Software

The next step in your journey to becoming a blockchain miner is downloading a mining software client. As is obvious, mining software is necessary for participating in the competitive process to validate new blocks on the blockchain network.

Mining software provides an interface for connecting to the blockchain network—that is, if you choose to go solo. For those who wish to join forces with other miners, the software client connects the node to the mining pool.

You can also control your miner's settings from the software interface. This includes everything from the clock speed to the system's fan speed.

There are many mining software products out there, but your needs may limit your options. For example, you should consider your hardware before selecting a blockchain mining software program.

Some blockchain mining software offerings have very specific device requirements and won't run on the wrong hardware. Others may be programmed to work exclusively on a particular operating system (Windows, Linux, Mac OS) or run on any OS.

Here is a list of the five most popular blockchain mining software you can choose:

Set Up Blockchain Mining Hardware

Building—and running—your blockchain mining hardware setup is the hardest and most expensive part of the blockchain mining process. And this has to do with changes in the blockchain mining industry over the years.

In Bitcoin's early days, anyone could run a miner node with nothing but a stable internet connection and a server-grade CPU. However, the addition of more people to the network made Bitcoin mining increasingly difficult.

To compensate, miners resorted to purchasing more expensive and powerful devices to increase their chances of securing block rewards. This coincided with the introduction of powerful Graphics Processing Units (GPUs), which offered 100x the processing speed of a regular CPU.

But mining technology never stopped developing, and the first Application-Specific Integrated Circuit (ASIC) machines arrived in 2013. ASICs are powerful computing units built specifically for mining and are more powerful than even GPUs.

While ASICs are more efficient than GPUs, their purchase and maintenance costs can run into thousands of dollars. Moreover, rapid development in technology means ASICs are getting obsolete as more powerful models hit the market.

You don't need to invest in a high-powered ASIC device immediately. With enough time on your hands, you can build your blockchain mining hardware from scratch. But it won't be cheap, so make sure you have enough money to cover the project.

What you're building is called a mining rig—which is just like any computer, except that it has more graphic cards (GPUs). A mining rig doesn't use a standard PC case since there's no way to fit that many GPUs inside it. A standard PC frame will likely cause overheating and thermal throttle your GPUs.

Below is a list of requirements for building a basic mining rig:

  • Motherboard

The motherboard is a critical part of any mining rig. It determines the compatibility of other components, so you want to be careful when buying one.

  • Graphics Card

The graphics card, also known as Graphics Processing Unit (GPU) is at the heart of a mining rig's performance. You must select high-quality GPUs when setting up your mining station.

For now, the best GPUs are produced by AMD and Nvidia.

  • CPU

Not every component in your mining rig needs to be top-notch—and the CPU is one of them. You can use a basic Intel CPU, like a Celeron or Pentium model.

The exception is if you want to use the CPU to mine, which requires buying an expensive model, such as an AMD Ryzen. Still, mining with a CPU is rarely advised, given the associated costs and low returns.

  • RAM and Storage

The RAM is another component you can skimp on when building a blockchain mining station. RAM rarely affects mining performance, although you may need more RAM if you plan to mine with a CPU.

Non-CPU miners can make do with a basic 4-8GB memory stick. Other factors like your operating system may influence the size of your RAM. As far as we can tell, Windows OS needs 8GB RAM, while Linux OS can do with 4GB or even less.

  • Power Supply

How much power you need depends on what components your mining setup uses. Calculating the electricity consumption of the GPUs, motherboard, RAM, and CPU should help you figure out your power supply needs.

  • Cooling

Because mining rigs run heavy computations, it's common for them to get hot. You need to invest in top-tier cooling solutions for your mining rig to keep it running optimally.

Plus, you don't want to have your mining rig bursting into flames, do you? Yes, that can happen if you let it.

The best equipment for cooling mining equipment includes inline fans, box fans, and liquid coolers. Any one of these will keep your mining station at an ideal temperature (60°C to 70°C) and keep components from failing.

  • Frame

The frame is the last thing you need to buy before completing your mining rig. Frames come in different sizes, and your preferences may determine what size you want.

At the very least you want a frame that's strong enough to hold all your mining equipment. Durability is a worthy consideration, except you want to spend on frequent frame replacements.

You can choose to buy a prebuilt mining frame. This saves you the energy of building one from the ground up, although it costs a lot more than a custom-built version.

  • PCI-e Riser

PCI-e risers are cheap but important components in mining setups. They allow you to attach more graphic cards to your motherboard to increase the hash power.

Most motherboards have limited PCI-e lanes that allow for one or two graphic cards. With a PCI-e riser, you can connect additional GPUs via USB.

Building the mining rig is easy once you have the required equipment. From what we can tell, it's similar to building a gaming PC—so if you have technical experience, your mining rig should be up and running in no time.

Blockchain mining rig.jpg A blockchain mining rig. Source: Amazon

Here are some guides to help you start setting up your blockchain mining hardware:

How to Build a Mining Rig in 2021? (Nicehash)

How to Build a Cryptocurrency Mining Rig from Scratch (Software Testing Help)

How to Build a Mining Rig (YouTube)

How Easy is it to Mine Cryptocurrency?

Some may conclude that blockchains mining is easy since it involves calculating a random figure. However, cryptocurrency mining is more difficult than most people think.

The target hash often starts with some zeros, and the more leading zeros in the string, the harder it is to calculate. Blockchain protocols adjust the difficulty of the target hash depending on the number of miners on the network.

If there are more miners dedicating computing power (called the "hash rate") to validating transactions, then the mining difficulty increases. The reverse happens if the hash rate, i.e., the number of miners on the network drops.

Changes in mining difficulty ensure that the production of new blocks remains stable and predictable. For example, Bitcoin has an average block production rate of one block every 10 minutes.

Adjustments in mining difficulty keep the average block time, i.e., the time it takes to create a valid block remains roughly the same—irrespective of the number of miners on the network. Bitcoin's protocol is programmed to review and adjust the mining difficulty every 2,016 blocks (roughly two weeks).

With a current block reward of 6.25 BTC (around $250,000 at current prices), blockchain mining is a fairly profitable venture. As a result, the hash rate on the network has increased, leading to spikes in mining difficulty.

The higher mining difficulty means miners need more computing power than ever if they stand any chance of winning block rewards.

graph showing bitcoin historical hash rate.png Bitcoin's hash rate has been on the increase. Source: BuyBitcoinWorldwide.com

A node's chances of finding the target hash depend on how fast it can generate nonces to calculate the right value. Which in turn depends on the computing power (hash rate) of the node in question.

Nowadays, you're more likely to mine Bitcoin with an Application-Specific Integrated Circuit (ASIC) or Graphic Processing Unit (GPU) than a regular home computer. These devices have faster processing speeds and can quickly run through the millions of transactions needed to guess the value of the target hash before other miners.

Is Blockchain Mining Profitable?

Blockchain miners earn money from the block rewards they receive from validating new blocks. Block rewards vary across blockchains—Bitcoin miners earn 6.25 BTC for every validated block, while Ethereum miners earn 3 ETH in block rewards.

At current rates, block rewards in Bitcoin and Ethereum are worth around 250,000 USD and 9,000 USD. Given the attractive block rewards, it's easy to see why mining is a competitive sport these days.

However, there are many things to consider before thinking of profiting from mining. Here's a list to get you started:

  • Costs of equipment purchases, maintenance, and upgrades
  • Utility bills (mining is electricity-intensive)
  • Internet bills (you need up to 200GB per month and strong upload speeds to run a mining node)
  • Licensing and tax fees (some areas require miners to register and pay taxes)

Also, consider that block rewards reduce over time. The Bitcoin blockchain is pre-programmed to reduce the block reward in half every 210,000 blocks (roughly four years).

The "halving" as it is known has occurred at four-year intervals as this chart below shows, with the next halving set to occur in 2024. You can monitor Bitcoin halvings through this Bitcoin Halving Clock.

Bitcoin halving chart.png Bitcoin Halving History. Source: @ChartsBTC

Only 21,000,000 bitcoins will ever be mined, with more than the last bitcoin to be mined around 2140. After bitcoin production ends, miners will no longer receive block rewards but will earn money from transaction fees.

With spikes in Bitcoin's hash rate and target difficulty, it's increasingly difficult for solo miners to earn a considerable income. However, if you can spend well on building a supercharged mining rig with extreme hash power, then mining may be profitable for you.

The more sensible option for most new miners is to join blockchain mining pools. In a mining pool, different nodes contribute their computing power to a central node responsible for validating transactions.

By combining hash rates, blockchain mining pools have better chances of securing block rewards. The rewards are split among members of the mining pool according to the amount of hash power contributed.

Blockchain mining pools have grown in size, with popular pools like Ant Pool, Slush Pool, and Bitfury controlling a large amount of Bitcoin’s hash rate. While profits may be lower since you split rewards with others, a mining pool is a good way to start mining without incurring risk.

Picture showing a bitcoin mining pool.jpg A Bitcoin mining pool in Russia. Source: Bloomberg

Wrapping Up

Blockchain mining is essential for validating transactions on the blockchain network and keeping it functional. Miners are important players in the blockchain ecosystem and receive compensation for their efforts in the form of block rewards.

With the right mining hardware and software, you can become a blockchain miner and start earning. Before you start, though, run your income-expenditure calculations to know how long it will take you to break even