How Bitcoin Mining Works

Bitcoin is created and released into circulation via a process known as bitcoin mining, and this is how bitcoin mining works.

On the surface, bitcoin mining is actually quite a simple concept:

A bitcoin minerAny person who deploys computing resources to mine bitcoin, or may also refer to mining hardware that mines bitcoin. purchases some mining hardwareComputing hardware specifically designed and manufactured to mine bitcoin. and connects them to the Bitcoin network. The mining hardware performs high-speed guesses to solve mathematical puzzles as it validates bitcoin transactions around the world, placing them into blocks and adding them to the blockchainA system in which a record of transactions made in bitcoin are maintained as a public ledger across several computers connected to the Bitcoin network., and for the expense of time, cost and electricity, the first bitcoin miner to solve the puzzle is rewarded with new bitcoin released by the Bitcoin protocol. The bitcoin miner then sells his bitcoin on the open market to cover his running costs, and this is how new bitcoin end up in open circulation to be bought, sold, kept or spent.

Beneath the surface, a lot more goes on in the bitcoin mining process, as follows:

The following text may be a little technical for some, and if you find yourself struggling to grasp the idea behind bitcoin mining, feel free to skip this page and read Bitcoin Supply Parameters. Understanding the inner mechanisms of bitcoin mining is similar to understanding how a car engine works. You do not need to know exactly how an engine or internal combustion works to drive a car, but it will give you an understanding and better appreciation for the car you are driving. Likewise, you do not need to fully understand bitcoin mining to start using bitcoin, but it will allow you to appreciate and be aware of what goes on in between when a bitcoin is sent and received. If you’re ready, let’s begin!
Advertisement:

 

Bitcoin Mining and Block Solving

“Bitcoin mining is open to anyone who wishes to participate in mining to help validate bitcoin transactions and earn bitcoin as a reward. All that is needed are some mining hardware and the technical know-how to download and run the software. But that doesn’t mean it will always be profitable.”
  • Anyone can participate in bitcoin mining by purchasing mining hardware and downloading and running the Bitcoin software.
  • However, bitcoin mining will require some technical know-how and management of hashrates for it to be done successfully and profitably.
  • A miner connects his mining hardware and deploys computing power to the Bitcoin network to solve a mathematical puzzle, which involves verifying and compiling all bitcoin transactions around the world into a block roughly every 10 minutes and adds it to the blockchain. This is the gist of bitcoin mining, which is further elaborated below.
  • Bitcoin mining uses the hashcash proof-of-work function in its block solving process, which starts with the calculation of the block hashThe values returned by a hash function that is used to convert a data of arbitrary size into a data of fixed size, e.g. converting the words “apple” and “watermelon” into a unique 10-digit alphanumeric string each. by applying the SHA-256 algorithm twice to the current block headerSHA256 ( SHA256 ( Block_Header ) ), which is the combination of block version number, previous block hash, timestamp, Merkle rootthe hash of all the hashes of all the transactions that are part of the body section of a block, bits, and nonce a 32-bit random number used in a cryptographic communication only once and churned out by miners to derive a block hash that is less than or equal to the current target of the network.
  • Miners apply different nonces to the combination above at high speed to find a hash that is below the target hash. The target hash difficulty is expressed by the number of leading zeroese.g. 000000c2c4d565d64f1a7c22ffeb6e
    the more the number of leading zeroes, the harder it is to solve
    in the hash. The nonce is any random number between 0 and 231, and is applied by brute force guesses in rapid succession until the target hash is achieved.
  • The first miner to achieve this, and verified by other nodesComputers on the network running the Bitcoin Core program that fully validate bitcoin transactions and blocks and store a copy of the blockchain ledger record. in the network to be valid and correct, wins the block race and is awarded the block reward, which is a preset number of bitcoin (read Bitcoin Mining > Bitcoin Supply Parameters) plus all the transaction fees for that block.
  • The solved current block is then added to the Bitcoin blockchainA system in which a record of transactions made in bitcoin are maintained as a public ledger across several computers connected to the Bitcoin network. and the process above repeats itself for the next block.
  • To help understand the application of nonce to derive the required hash, you may watch the following visual demo:
     

The Blockchain

  • Almost every cryptocurrency will have its own blockchain where computers running its software on its network will help to maintain.
    For brevity, whenever blockchain is mentioned on this site, it is taken to mean the bitcoin blockchain.
  • The blockchain is a public ledger system which records every single bitcoin transaction that has taken place since the inception of Bitcoin in 2009. It is immutableunchanging over time
    or cannot be changed
    and thus cannot be altered.
  • As such, it is an append-only database, which means you can only add to the records, and cannot subtract or modify information along the way.
  • The blockchain public ledger is accessible 24/7 by anyone and is a means to verify if a bitcoin payment between two bitcoin addresses has been made and exactly when it was made.
    We will explore this in a later module and learn how to check a payment record with a block explorer.
  • A block of transactions compiled by the miner roughly every 10 minutes is added to previous blocks of transactions dating all the way back to 2009 in a series or a chain of blocks, hence the term blockchain.
  • the bitcoin blockchain
    Fig. A. New blocks are added to previous blocks every 10 minutes on average all the way back to the genesis block on 3rd January 2009 in a chain-like series, hence the term blockchain.
  • A block may consist of up to a few thousand transactions that took place during that 10-minute period.
  • As at January 2019, more than 556,000 blocks have already been mined in total. Let’s try an example to see the data in a particular block on the blockchain. Click here to open the block explorer for Block No. 480,000 in a new tab on your browser. You will see the information as shown in Fig. B. below. As highlighted in the red boxes, you can see that this block:
    • was mined at 11.25 pm (59th second) on 10th August 2017
    • was solved by the mining pool SlushPool
    • consisted of 2,117 transactions with a volume of 2,057.84 BTC
    • carried a block reward of 12.5 BTC with transaction fees totalling 1.47 BTC
     

    As the successful miner for this block, SlushPool had earned 12.5 + 1.47 = 13.97 BTC as reward.

    bitcoin block explorer
    Fig. B. Data in Block No. 480,000 of the blockchain provided by a block explorer at www.blockchain.com. You can search for data in other blocks by entering the block number in the search field at the top menu.
Advertisement:

 

Security and Hacks

  • Bitcoin uses the resource-intensive hashcash proof-of-work function based on the SHA-256The Secure Hash Algorithm with an output size of 256 bits designed by the National Security Agency (NSA) first published by the National Institute of Standards and Technology (NIST) in 2001. for a high level of security and a consensus system as a probabilistic solution to the Byzantine Generals’ ProblemA scenario where some parties in a distributed network may not be trustworthy, and any node or message that is false or corrupt may result in an attack or collapse of the network. – a classic trust problem faced by any distributed network. In the case of bitcoin mining and the blockchain, it implies that confidence in consensus reached grows incrementally with every block added to the blockchain and is sufficient for its purpose although it never reaches 100%.
  • Because of that, bitcoin mining is designed to be difficult and resource-intensive, in order to safeguard the security of the blockchain and discourage a 51% attackan attack on the bitcoin blockchain by a group of miners with more than 50% of the network’s global mining hashrate on the network, and to ensure that the blocks are solved by miners at a steady rate of 10 minutes per block on average (see Adjusted Difficulty below).
  • As at end 2017, the resources required to perform a 51% attack on the bitcoin network was estimated to be around US$30 billion. Such a hack is only hypothetical and has never taken place as it requires a huge amount of money and computing resources, and the attackers would only be able to prevent new transactions, halt payments and reverse transactions or double-spendthe scenario where bitcoin or other cryptocurrencies are spent twice, without the ability to create new coins or alter previous blocks on the blockchain.
  • As more miners get on the Bitcoin network, the resources required to perform a 51% attack today becomes significantly higher. At such a prohibitive cost, hackers will need to consider if it is worthwhile to hack the Bitcoin network at all, as it is generally considered more productive and profitable to instead invest in mining hardware and mine a genuine bitcoin instead of trying to manipulate the blockchain with malicious intent. Or, it would simply be more prudent to just buy a bitcoin (or a hundred) from the open market.
  • Large group of miners or mining pools are also discouraged from deploying hashrates approaching 50% of the network strength as this brings about fear in the bitcoin community that the network may be compromised or manipulated, which would then likely in turn devalue bitcoin as a cryptocurrency, including the current bitcoin holdings of these miners. This deters human greed and ensures fairness in distribution to a great extent.
  • Referring to the live global hashrate distribution chart, you will notice that the large mining pools would rarely approach 30% of the network strength (see Fig. C. below), even when they have the capabilities and means to do so, for the reasons stated above. You could say the bitcoin network looks after itself pretty well.
    hashrate distribution chart
    Fig. C. The hashrate distribution chart showing the largest mining pools and their respective hashrates on the Bitcoin network. Mining pools would rarely approach 30% of the network strength to prevent jeopardising the trust in the network. Source: www.blockchain.com/pools

A Brief History of Bitcoin Mining and Its Hardware

Bitcoin mining was not always carried out with the ASIC mining hardware that is popular in use today. The following is an outline of the changes in hardware and technology over the course of bitcoin mining so far. As you read below, keep in mind the factors which will affect a miner’s profitability, i.e. the processing powerhow fast the machine can process and solve problems and efficiencyhow much electricity the machine will consume to solve a given problem of the hardware:

  • When Bitcoin first began in 2009, bitcoin mining was carried out by using the processing power of CPUThe central processing unit is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logic, controlling, and input/output (I/O) operations specified by instructions.s in desktops and laptops.
  • Shortly after that, miners learned that they could harness the higher power and efficiency of GPUThe graphics processing unit is a specialised electronic circuit designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device.s or graphics cards to mine faster than CPUs. While CPUs could still probably be used to mine at that time, miners were losing out to those who had deployed GPUs, in terms of number of blocks solved and running costs. This made GPUs far more favourable for mining than CPUs.
  • By mid 2011, miners discovered that FPGAFPGA or field-programmable gate array is an integrated circuit designed to be configured by a customer after manufacturing to perform a specific task. hardware could run at high hash rating and at the same time consume little power, making them very efficient machines for the purpose of bitcoin mining. FPGAs were more efficient than GPUs, and made CPU mining less viable.
  • In 2013, ASIC mining came into the scene. ASIC minersApplication-Specific Integrated Circuit mining hardware which is specifically designed and built only for the purpose of mining. are much faster and more efficient than any mining hardware that came before. This rendered all other previous hardware obsolete for mining bitcoin, and GPUs and older hardware were then feasibly used to mine other altcoinsalternative cryptocurrencies other than bitcoin such as Ethereum and Monero. ASIC miners (table below) are still used to mine bitcoin today, although they have gone through several iterations since they were first used.
  • how bitcoin works how bitcoin works how bitcoin works
    BITMAIN MODEL: AntMiner S5 AntMiner S7 AntMiner S9
    YEAR RELEASED: December 2014 August 2015 May 2016
    HASHRATE: 1.155 TH/s 4.73 TH/s ±5% 13.5 TH/s ±7%
    POWER CONSUMPTION: 589 W 1293 W 1323 W
    POWER EFFICIENCY: 0.51 W/GH 0.27 W/GH 0.098 W/GH
    ASIC DIMENSION: 28 nm 28 nm 16 nm
    N.B. Note that there are also other models by Bitmain prior to the three shown above: AntMiner S1 (180 GH/s), AntMiner S2 (1000 GH/s), AntMiner S3 (450 GH/s), AntMiner S4 (2 TH/s) etc. Other ASIC mining rigs are also sold by other companies such as BitFury, Halong and others.
  • Eventually as the number of miners grew around the world, miners realised that there were days when their hardware would be running but not generating any revenue in bitcoin. In order to increase their chances, they band together and form what is known as pool miningPool mining consists of large numbers of mining hardware deployed together to mine as a group.. This increased the chances for a pool to solve blocks daily, and the rewards can then be distributed to members of the pool. Although the reward needs to be shared, it at least increases the likelihood of everyone in the group earning bitcoin on a daily basis.
    E.g. You could think of individual versus pool mining as a fisherman who goes out to sea on a boat with a fishing rod, versus 10 fishermen going out to sea in the same one boat with 10 fishing rods. There may be days when the sole fisherman may not have any fish to eat, but a high chance that the 10 fishermen could catch at least one fish a day to be shared amongst all ten of them, although each with a small share of the fish.
  • Antminer S15
    As of end 2018, the AntMiner S15 began shipping out, with a chip dimension of 7nm and a hashrate capacity of 28 TH/s.
  • Around this time, cloud mining services also began, which offers anyone to be involved in bitcoin mining without having to worry about purchasing and upgrading hardware. A company owns and manages all the mining hardware in a remote farm location usually where cheap electricity is available, and one only needs to pay the cost of renting hashrateMeasured in mega-, giga-, tera-, peta or exahash per second, hashrate is a measure of the performance of a mining hardware and describes the speed at which it can compute to solve the block cryptographic puzzle. and other fees to get started. Bitcoins earned are usually credited into the person’s mining account wallet or directly into his or her own bitcoin wallet. While cloud mining may seem like an easy and hassle-free way to get involved in mining, it does carry its own set of risks as the person does not have full control over the mining hardware and payouts.

These days, bitcoin mining is only feasible (though not necessarily profitable) when done via a mining pool, and the major mining pools can be seen at www.blockchain.com/pools.

individual miners or mining farms would point their hashrates to one of these pools and mine as a collective and share the rewards with others in the same pool. Not all mining pools are open to the public, and some are privately owned by stakeholders of the pool.

Advertisement:

 

So, is Bitcoin Mining Profitable?

While the bitcoin ecosystem may be a free marketAn economic system in which prices are determined by unrestricted competition between privately owned businesses. system, it does not mean that bitcoin mining will always be profitable. The profitability in bitcoin mining generally depends on the following six key factors:

  1. Operation of high efficiency mining hardware
    Higher efficiency mining hardware enables the miner a higher chance to solve the block puzzle ahead of other miners and at the same time, utilises less power to save on electricity cost to maintain profitability, i.e. more of the bitcoin rewards earned can be retained as profits.
  2. A high collective hashrate or large mining pool size
    A high collective hashrate or large mining pool size provides the miner with a better probability of solving blocks on a daily basis, but must also know how many units to switch off so as not to incur more overheads than is necessary to obtain the same rewards.
  3. Ability to upgrade machines as soon as the current technology becomes obsolete
    Often overlooked, the miner has to be equipped financially and infrastructure-wise when it comes to repairing or upgrading hardware in a timely manner to keep up with the competition and have the facilities to support the entire setup, including the security to prevent thefts.
  4. The price of bitcoin
    The price of bitcoin has a huge bearing on a miner’s profitability as a portion of the bitcoin earned from mining is converted to cash to pay off the operational costs such as electricity, cooling, space rental, pool fee etc.
  5. Access to cheap electricity and other operational overhead costs
    One of the critical factors to ensure profitability is to secure access to cheap electricity or obtain low electrical tariffs to keep running costs down.
  6. Setup in cool climate and clean environment
    Mining hardware generates a lot of heat and a farm setup in naturally cool climate and clean outdoor air means unnecessary reliance on air-conditioning or powered cooling, at the same time keeping HEPA filters clean and maintenance costs low.

Here is a short video to summarise what bitcoin mining is about.

Why Bitcoin Mining Is So Important

From the discussion so far, we have seen that bitcoin mining is a significantly important aspect of the entire Bitcoin ecosystem. It is through bitcoin mining that:

  • bitcoin transactions across the globe are verified and validated.
  • bitcoin transactions are placed into blocks and added to the blockchain as an immutable record and public ledger accessible by anyone at all times.
  • the blockchain is secured against hacks and attacks.
  • double-spending is prevented.
  • new bitcoin is introduced into circulation and ensures fairness in its distribution.

From here, it is easy to realise that without bitcoin mining, the Bitcoin ecosystem will cease to exist in any meaningful manner. Bitcoin mining helps to keep the bitcoin network stable, safe and secure. As such, bitcoin mining is an integral and fundamental process for Bitcoin to function in the real world.

Now that we have seen how bitcoin mining drives the entire Bitcoin ecosystem, we can take a look at the important mechanisms that keep the Bitcoin economy in check – the Bitcoin Supply Parameters.


Ledger Nano X - The secure hardware wallet
Ledger Nano X - The secure hardware wallet