cryptocurrency data center servers

The term mining in the context of digital currencies may conjure up various images in your head, with parallels likely drawn to gold or coal extraction from the earth.

In reality, cryptocurrency mining is an entirely digital paradigm that simply facilitates honest collaboration among strangers. While mining does sometimes generate economic value in the form of rewards, it serves the greater purpose of keeping a decentralized network functional and secure.

If that description sounds too complicated, don’t worry as it is surprisingly straightforward. In the following sections of this article, let’s explore what it means to mine a digital currency and why such a system needs to be present in the first place. We’ll also discuss nuanced aspects such as its profitability and potential impact on the environment along the way.

While the majority of this article will focus on Bitcoin mining, the same principles apply to most other cryptocurrencies. The only exceptions are digital assets that employ alternative methods to achieve consensus, such as Cardano.

Why is cryptocurrency mining necessary?

The first and most well-known application of mining involves Bitcoin, which was created by the pseudonymous Satoshi Nakamoto. While attempts at creating electronic currencies were nothing new even back in 2009, Bitcoin was notable because it was the first truly decentralized currency.

Prior to Bitcoin’s inception, all currencies relied on a central authority of some sort. This approach is not ideal for a number of reasons, not least because you have to trust the issuer and everyone higher up in the hierarchy. Even a common service like PayPal, for instance, has complete autonomy over funds you store on the platform and could freeze them at any time.

Bitcoin, however, flattened this centralized hierarchy. You don’t need permission from a central bank or intermediary to use it, nor are you required to sign anything. In fact, all you need is an internet connection. And once you acquire some cryptocurrency, nobody can confiscate it behind your back.

Bitcoin achieved this level of decentralization and security through an algorithm called Proof of Work. Mining is simply the real-world application of this algorithm.

Put simply, Bitcoin employs a system wherein anyone and everyone can propose new transactions. However, these transactions are only considered valid when other participants on the network reach an agreement on their legitimacy. The system also ensures that past transactions cannot be edited or reversed by anyone with malicious intent — granting Bitcoin the property of immutability.

While arriving at such a unilateral agreement may sound simple, it is actually an extremely difficult endeavor — especially when real money is on the line. Would you trust a bunch of strangers to deliver your money to the right person? Most likely not.

To that end, Satoshi Nakamoto believed that the only way to achieve consensus in a cryptocurrency network was to make some users work for it in exchange for some rewards. And, thus, the system was named “proof of work.”

Proof of work is essentially one CPU, one vote.

Satoshi Nakamoto

We’ll explore this interplay of “work” and incentives in a later section. For now, know that every stakeholder in the cryptocurrency ecosystem is incentivized to act in the best interests of the network, so they are extremely unlikely to support malicious acts.

bitcoin mining

Credit: Marco Verch

What does mining achieve?

Let’s look at a typical cryptocurrency network to answer this question. Participants can be broadly classified into three groups:

  1. Users: These are end-users — participants like you and me — that send and receive funds. Users initiate transactions through their crypto wallet, which is essentially a piece of software. That, in turn, broadcasts relevant details (such as the amount and destination address) to the rest of the network.
  2. Nodes: Nodes are volunteer users that maintain a copy of the Bitcoin blockchain on their computers. They also take on the responsibility of acknowledging new transactions broadcast by the users. Finally, nodes enforce a comprehensive list of network-specific rules that all incoming transactions must adhere to.
  3. Mining nodes: These are specialized nodes that volunteer to verify the aforementioned incoming transactions. There is no risk or entry fee involved, as long as the miner can contribute computational power towards the verification process. In return, they receive compensation in the form of token rewards, transaction fees, or both.

As you can probably tell by now, there is a very clear symbiotic relationship between all three groups. Nodes will not accept illegitimate transactions from users. Meanwhile, miners have to abide by the rules of the network in order to receive their compensation.

Large amounts of computational power is neither cheap nor infinite, so miners spend it judiciously by their own volition. And therein lies the beauty of mining — it enables decentralized consensus and is self-regulating in nature.

It’s worth stating that you don’t have to understand mining in order to simply use a cryptocurrency. You probably don’t think about how banks process transactions on the backend either.

Most digital exchanges and wallets these days have simplified user interfaces. Under the hood though, Bitcoin and most cryptocurrencies use a ledger that keeps track of all transactions since the birth of the network. This ledger is what is commonly referred to as a blockchain. The term also offers up a pretty big clue to understanding how mining works.

In the context of Bitcoin, new and unconfirmed transactions are collected in a block every 10 minutes. This block will also contain a timestamp and a reference to the block that came before it. This means that all blocks are linked to each other, going back all the way to 2009 — kind of like a block…chain, get it?

So what does all of this have to do with mining? Quite a bit, actually. Miners are tasked with generating these blocks, and while the process is quite straightforward, it is anything but easy.

Read more: What is a blockchain?

How mining works: A cryptocurrency transaction’s lifecycle

Shortly after a user’s wallet broadcasts a transaction, a nearby node will pick it up and add it to the Bitcoin mempool. The mempool is basically a space where unconfirmed transactions live.

Every few minutes, miners from around the world reach into this mempool and pick a bunch of transactions to include in the next block. A typical Bitcoin transaction is under 1KB, so miners can fit quite a few transactions into a single 1MB block. Still, miners generally prioritize transactions with the highest fees for maximum profitability.

Once the block has been assembled, miners can’t just race to submit it at this point. That would be a rather unfair system, where connection speed would be the sole determining factor.

Instead, each miner has to spend computational power to solve a mathematical function unique to that particular block. The first miner that computes a valid solution has their block accepted by other nodes. This is why the algorithm is referred to as proof of work — miners have to prove their work in order to earn their reward.

But what is this mythical mathematical problem and what does a valid solution look like? In a nutshell, miners run a computer algorithm that takes the block’s data as an input and generates a fixed 256-bit output. The output is usually represented in the hexadecimal format, where each character is four bits in size.

For instance, the text “I love Bitcoin” would have the corresponding hash that is exactly 256-bits long (represented by 64 hexadecimal characters):

024a8a19f6d71e090e93602b64d0fe0d83fd0e22841778e5d790e54d307b0104

Generating one such hash is a pretty trivial job for any computer, and even humans can do it. However, going the opposite way (finding the original input from the hash) is nigh on impossible for anything less than a supercomputer.

So if even a human could do it, where is the challenge? Well, cryptocurrencies impose an arbitrary restriction to increase the difficulty of finding a winning hash. In Bitcoin’s case, miners need to find a hash that has at least 19 leading zeros. Take the following hash for example, which comes courtesy of Bitcoin block 692174:

0000000000000000000100a4681fe264d4ac31e6a5fd0ce8b78a0f807a98289b

This is achieved by adding a random number, called a nonce, to the end of the block data for every single hash calculation. In other words, each time the input is modified, a new corresponding hash is generated. For the aforementioned block, the nonce value is 1,567,882,533. Armed with the block data and the nonce value, you could calculate the hash (by hand or computer code) to verify that the work has indeed been done.

In this way, miners from around the world calculate trillions of hashes every second until they find the first one that meets the requisite criteria. The performance of mining hardware is typically measured in terahashes per second. Even then, you would need an army of them to find a single valid solution.

How mining prevents history from being rewritten

Remember how every block is linked to the preceding one in a blockchain? Now consider that any potential attacker would not only need to compute the hash of the next block faster than everyone else, but also that of every single previous block. And if the chain is broken even once, the network will automatically know to discard the proposed solution.

Satoshi Nakamoto explained transaction permanency in the Bitcoin white paper as well. More specifically, “Once the CPU effort has been expended to make it satisfy the proof of work, the block cannot be changed without redoing the work.”

Since older transactions are more trustworthy, merchants accepting payments in Bitcoin will often wait for your payment to age by a few blocks. This is also known as “confirmations” in many wallet programs, such as Electrum:

Image shows Bitcoin wallet with two transactions. Both have achieved one confirmation.

Credit: Calvin Wankhede / Android Authority

In the above screenshot, the clock at 2:00PM signifies one-of-six confirmations for both transactions. Six confirmations are the gold standard used to guarantee the success state of a Bitcoin transaction. However, three are often accepted for low-value transactions as well.

Notably, new blocks are discovered on the Bitcoin network roughly every 10 minutes or so. If a significant deviation occurs, the network automatically adjusts the hash calculation difficulty to bring it back in line.

You may wonder what happens to the miners that fail to compute a valid solution in time. The answer’s pretty simple: they get nothing. Since blocks are found roughly every 10 minutes in the case of Bitcoin, everyone starts over and tries to find the next solution.

Cryptocurrency mining is an arbitrary winner-takes-all situation in which the only guarantee is mathematical probability.

If you dedicate a decent amount of computational power to the network, the laws of probability dictate that you will stumble upon a solution sooner or later. A miner contributing 1% of the total Bitcoin hash rate, for instance, has a 1 in 100 chance of finding a block.

Understanding how miners are incentivized

We now know how mining works and why it is important. But how do miners receive compensation for their work? Put simply, there are two ways in which a cryptocurrency network rewards miners, namely block rewards and transaction fees.

In the case of Bitcoin, each block generates 6.25 BTC — and is credited only to the miner with the winning hash. In 2009, that figure was 50 BTC, which is how we now have 19 million Bitcoin in circulation.

Since the network dictates a self-imposed limit of 21 million Bitcoin, mining will continue yielding rewards until that threshold is reached. However, Bitcoin’s block rewards drop by half every four years. This means that the final 21-millionth token will not enter circulation until the year 2140.

Block rewards work differently depending on the currency. Ethereum, for instance, has a fixed 2 ETH block reward with no hard cap.

Transaction fees represent the second source of revenue for miners. As previously mentioned, transactions with the highest fees in the mempool are prioritized by miners. This leads to a bidding war when the network gets busy, as thousands of individuals pay higher and higher amounts to settle their transactions as quickly as possible.

Data from Ethereum block 12907670

Credit: Etherscan

The above screenshot of Ethereum block 12907670 highlights all that we’ve learned so far. The total reward earned by the miner in this instance was 2.4467 ETH. That figure comprises both the 2 ETH block reward and a 0.4467 ETH transaction fee component. It also tells us that the block included over 200 transactions and was 99.94% full.

Notably, Ethereum began destroying transaction fees in August 2021 as part of the London network upgrade. This move was aimed at making the network deflationary, since Ethereum’s total supply has been on a steady climb for years now.

Given how burning or destroying fees affects a miner’s bottom line, it’s not surprising that the mining community vehemently opposed this proposal initially. Nevertheless, it shows that while miners have definite revenue streams, the specifics can differ significantly from one cryptocurrency to another.

Antminer 19Series 1024x534 1

Credit: Bitmain

The economics of mining: Not a quick buck

Mining may seem extremely lucrative if you are in the know. However, simply participating in the process does not guarantee a profit.

As you can imagine, there are significant costs involved in running a mining operation. At one point in time, a desktop or laptop could mine several Bitcoin within a matter of days. These days, however, even with a few dozen high-performance computers, you might never find a block. This is because cryptocurrency mining has become increasingly difficult in recent years, computationally speaking.

Specialized hardware, or application-specific integrated circuits (ASICs), excel at calculating hashes and nothing else. They pretty much leave consumer, off-the-shelf hardware in the dust. The upfront cost of acquiring this sort of hardware is a huge deterrent for average folk, however, and the Chinese manufacturers that make them usually prefer selling in bulk.

While some cryptocurrencies like Ethereum and Monero have employed ASIC resistance to encourage miner diversity, others like Bitcoin are now ASIC-only. Still, this means you could mine Monero on the computer or smartphone you’re reading this on, as long as your hardware is relatively recent.

Ease of mining aside, whether it is worthwhile for you depends on one more crucial factor, namely the cost of electricity. In many cases, it can be a deal-breaker.

Crunching the numbers

Take the Antminer S9, for example, which is an ASIC miner from September 2017. It can output 13.5 terahashes per second and has a rated power draw of 1,300 watts. If you plug those numbers into the profitability calculator at CryptoCompare, it quickly becomes evident that this setup is not profitable at all.

Chart showing Bitcoin mining profitability on Antminer S9

The biggest contributor to this problem is the cost of electricity. Even though the Antminer S9 can earn you 0.0037 BTC or $120 per month in 2021, you would pay as much or more in electric costs. Does this mean that the S9 is useless or e-waste? Not exactly.

While we’ve estimated the cost of electricity to be $0.2 per kilowatt-hour, that figure can differ based on the region you live in. Germany’s average electric prices, for example, hover around $0.3/kWh. In Iran, on the other hand, you can expect to pay as little as $0.01/kWh.

It’s not surprising then that mining operations have cropped up in regions that have cheap and abundant sources of electricity. In fact, US-based mining company Riot Blockchain relies on solar, wind, and hydroelectric sources for around 56% of its electricity needs. With the low energy costs on self-owned solar installations, inefficient hardware becomes profitable too.

For modern hardware such as the latest Antminer S19 Pro the profits are even more lucrative.

Chart showing Bitcoin mining profitability on Antminer S19

Keep in mind, however, that individual pricing for such hardware can easily approach $10,000. Unless you’re buying straight from a factory, it’ll take you months to make back your initial investment. And by that time, you can expect profits to slowly recede as well due to increased competition.

So is mining unprofitable? Absolutely not — and the chip shortage of 2021 is proof. However, mining is certainly a game of hyper-optimization that requires quite a bit of technical expertise and patience.

See also: The global computer chip shortage explained

Do cryptocurrency miners operate independently?

For a cryptocurrency to be truly decentralized, each miner should ideally only control a tiny fraction of the network’s total hash rate. Indeed, most miners back in the early days of Bitcoin were individuals who used their laptops or computers to mine new blocks.

Over time, however, the allure of profit has motivated many enterprising miners to purchase entire data centers’ worth of hardware for maximum profit. This presents a unique problem since the probability of finding a block has become astronomically tiny for most small-scale miners. Thankfully, a solution — or more appropriately, middle ground — to this problem has emerged in the form of mining pools.

Mining pools are what you get when a group of people band together and combine their computational power to boost their chances of finding the right hash. Any reward earned is then split between all participants in the pool, depending on the amount of power they contributed to finding that block.

Joining a pool vastly reduces the risk of running into bad luck for everyone involved since probability is on their side. Pools generally charge a small fee to coordinate everything — typically under one percent for large-scale miners.

Since cryptocurrency blockchains are transparent by design, we can see exactly how influential these pools are.

Pie chart showing Bitcoin mining pool distribution

Credit: Blockchair

In the case of Bitcoin, over 70% of the network’s total hash rate comes from known mining pools. However, no pool controls a majority stake, which means that the cryptocurrency is sufficiently decentralized.

Hash rate centralization is a very tangible threat to cryptocurrencies — especially smaller ones that struggle to attract miners. When one entity controls a majority stake in a network, the cryptocurrency becomes vulnerable to attacks. Looking at Bitcoin’s hash rate figures, however, there is no real cause for concern.

Cryptocurrency mining is an extremely contentious topic these days, with many contradictory or abstract explanations thrown around. Hopefully, this article has shed some light on what goes on behind the scenes and how a system of incentives keeps a trillion-dollar network honest.

For further reading, check out our deep-dives into Bitcoin and Ethereum — the latter of which is planning to do away with the proof of work algorithm and cryptocurrency mining altogether.