What is Bitcoin Mining?
– The Role of Hash Functions in Bitcoin Mining
– How Does Bitcoin Mining Work?
– How Many Bitcoins Are There?
– Rewards of Bitcoin Mining
– Cost of Bitcoin Mining
– How to Start Mining Bitcoin
Bitcoin is really three things: It is a protocol (or set of rules) that defines how the network should operate. It is a software that implements that protocol. It is a network of computers running software that uses the protocol to create and manage the Bitcoin currency.
In 2008, the blockchain concept was introduced by Satoshi Nakamoto in a whitepaper (pdf) as a core component to support transactions of Bitcoin. As the technology that powers cryptocurrencies like bitcoin, blockchains are associated with volatile and (as yet) largely unregulated financial trade, but they are also about more than money. A blockchain could also be a programmable system for secure digital ownership and greater transparency of trade, even between strangers.
The purpose of bitcoin mining is to issue new bitcoins; confirm transactions; and keep the Bitcoin network secure.
In essence, a bitcoin is a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.
The term mining is used as a metaphor for creating new bitcoins, since it requires (computational) work just as mining natural resources requires (physical) work. The tokens that miners find are virtual and exist only within the digital ledger of the Bitcoin blockchain.
Mining bitcoins, or any other cryptocurrency for that matter, verifies transactions by evaluating them against the transactions that happened before. This is an essential function of cryptocurrency as it prevents double-spending, collects transaction fees and creates the coin supply.
The Role of Hash Functions in Bitcoin Mining
The hash, also called hash function, is a 64-digit hexadecimal number that is a fundamental building block of cryptocurrencies and the central security element in a blockchain. It is an element of cryptography that is used to specify data records of any size in a fixed length.
The hash function existed long before the advent of bitcoins. For instance, SHA-256 is used in some of the most popular authentication and encryption protocols, including SSL, TLS, IPsec, SSH, and PGP. In Unix and Linux, SHA-256 is used for secure password hashing.
In encryption, data is transformed into a secure format that is unreadable unless the recipient has a key. In its encrypted form, the data may be of unlimited size, often just as long as when unencrypted. In hashing, by contrast, data of arbitrary size is mapped to data of fixed size. For example, a 512-bit string of data would be transformed into a 256-bit string through SHA-256 hashing.
There are many different hash functions, each with different properties. The hash function used in Bitcoin is the SHA -256. SHA stands for Secure Hash Algorithm. The specialty of the function is to guarantee security. SHA-256 is a patented cryptographic hash function that outputs a value that is 256 bits long.
A hash function always spits out random results, akin to lottery results. However, it is deterministic. This means that the same input (what is fed into the hash function) delivers the same output. Different inputs provide completely different hashes. The hash function is highly sensitive; if only one bit of the input changes, the entire output (the resulting hash) changes.
You can play around with a SHA-256 online generator and see how it works.
How Does Bitcoin Mining Work?
Participants – known as miners – compete to earn bitcoins by applying computing power in a process known as Proof-of-Work (PoW) to add new blocks to the chain that constitutes the ledger (the blockchain). The process is named PoW because only miners who have proven to have dedicated sufficient resources (work) will have a chance at mining bitcoins.
The data that a miner inputs into the SHA-256 hash function include all the current transactions which fit into the block’s size limit, the previous block’s hash result, and the nonce. The nonce is a random value the miner changes with each hash attempt to get a new output. Even a tiny change in input produces a completely different output.
Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it.
Before a block can be added to the blockchain, the information contained in it must be verified by the Bitcoin network. In order to create a new block, miners change the nonce as often as it takes to generate a hash whose number is below the target. The target gets stored in the bits field in the block header of every block. This is how it works:
The initial (and maximum) target value is hard coded into the source code of every bitcoin node. It was probably a best guess by Satoshi Nakamoto of a good starting point for a difficult-enough target that would result in a 10-minute interval between new blocks.
This 10-minute interval is another hard-coded feature of Bitcoin: The protocol contains a goal of adding six blocks per hour, or one every 10 minutes. Of course, the speed of how fast blocks are added to the network cannot be predicted and depends on how fast miners are working and how many computing resources are thrown at finding hashes. For that reason, the difficulty for targets adjusts every 2016 blocks (roughly two weeks) to try and ensure that blocks are mined once every 10 minutes on average. It therefore creates a consistent time between blocks and a consistent issuance of new bitcoins into the network.
The difficulty is a measure of how difficult it is to mine a Bitcoin block, or in more technical terms, to find a hash below a given target. A high difficulty means that it will take more computing power to mine the same number of blocks, making the network more secure against attacks.
At the end of October 2021, the difficulty level was at 21.6 trillion, meaning that the chance of a computer producing a hash for a block below the target is 1 in 21.6 trillion. You can track Bitcoin network difficulty levels here.
As the target is continuously reducing, in November 2021 for instance, the hash of block 708177 on the Bitcoin blockchain already contains 20 leading zeroes. You can check the latest Bitcoin blocks here.
Once the hash is found, the block is closed, and it is added to the blockchain. After successfully mining a block, miners are rewarded with newly created Bitcoins and transaction fees.
How Many Bitcoins Are There?
The rate that new bitcoins are added to the circulating supply gradually decreases along a defined schedule that is built into the code. Starting at 50 bitcoins per block (a new block is added approximately every 10 minutes), the issuance rate is cut in half approximately every four years.
In May 2020, the third halving reduced the issuance rate from 12.5 to 6.25 bitcoin per block. At that point 18,375,000 of the 21 million coins (87.5% of the total) had been mined. The fourth halving, in 2024, will reduce the issuance to 3.125 bitcoin, and so on until approximately the year 2136, when the final halving will decrease the block reward to just 0.00000168 bitcoin.
Rewards of Bitcoin Mining
The hardware and energy costs associated with Bitcoin mining contribute to the security of the network in a decentralized fashion along game-theory driven principles. However, these costs have increased substantially over time.
The network incentivizes users to participate in the block validation process by assigning newly mined bitcoins to the first miner who randomly finds a hash with a value smaller than the target. As shown above, currently the reward is 6.25 bitcoin per newly mined block.
A second component of miners’ rewards are the fees associated with all transactions in the current block. End users wishing to make a transaction must attach a fee to the proposed transaction as incentive for miners to include it in the next block.
Currently, the Bitcoin block size is limited at 1 MB. Since bitcoin transactions vary in size, there are also a varying number of transactions included in each block. This number is roughly between 800 and 3000. Again, check the latest Bitcoin blocks here to see the number of transactions included.
If the demand of transactions is larger than the available block space, then you need a way to prioritize which transactions get into a block. This is done via transaction fees that users are willing to pay in order to incentivize miners to add this transaction to the next block. This fee usually is a few US dollars but has already reached US$60 during the 2017 crypto boom. You can check historical and actual values here.
The Cost of Bitcoin Mining
Of course, the rewards of miners have to be measured against their cost. No longer can cryptocurrency be mined on a desktop or laptop computer with any degree of speed and efficiency. Special mining hardware ( called rigs) and software have been developed to deal with the ever-increasing hash rates required to be a successful miner.
The hash rate (also called hash power) is the speed at which miners operates. Specifically, it is the speed of the computing device used by miners to develop one bitcoin (or a unit of any other cryptocurrency). To be successful at mining, speed is of the essence since the miner is trying to find the right hash before anyone else does.
Hash rates are measured in units of hash per second, meaning how many calculations per second can be performed. In October 2021, the Bitcoin network reached a hash rate of 158 terahashes (1 terahash is 1 trillion hashes) per second. Check out the current statistics about hash rates in the Bitcoin network.
A typical bitcoin mining rig is a barebones computer with multiple graphics cards or GPUs, instead of the single-card standard; or, more realistically, an application-specific integrated circuit (ASIC) which can cost up to $20 000:
Examples of ASIC Bitcoin Mining Hardware
|Miner||Hash Power||Power Consumption||Price|
|Antminer S19||95 TH/s||3250w||∼$12,000|
|Antminer S19 pro||110 TH/s||3250w||∼$16-17,000|
|Whatsminer Asic M30S+||102 TH/s||3400w||∼$14,000|
|Avalon 1166pro||72 TH/s||3024w||∼$7,700|
|Avalon 1246||85 TH/s||3400w||∼$9,800|
Crypto mining businesses have many thousands of rigs in one location. These farms generate large amounts of heat. Which require cooling. Which requires even more energy.
The Digiconomist's Bitcoin Energy Consumption Index estimates that one Bitcoin transaction takes 1,858 kWh to complete, or the equivalent of approximately 64 days of power for the average US household.
To put that into money terms, the average cost per kWh in Europe is 21 cents, in the US 13 cents. That means a Bitcoin transaction would generate more than $390 in energy bills in Europe and $240 in the US.
Add to that the cost of buying and renewing the mining hardware plus the cost of infrastructure cost of the mining farm.
If you want to get into detailed calculations, check out this bitcoin mining profit calculator.
How to Start Mining Bitcoin
As we’ve seen, the days where you can mine bitcoins on your own on your desktop computer are long gone. If you really want to try your luck at bitcoin mining, your best option is to join with other individuals to mine bitcoin cooperatively in what are called mining pools.
Bitcoin mining pools are groups of cooperating miners who agree to share block rewards in proportion to their contributed hash power. There are about 20 major mining pools, about 75% of which are located in China. This statistic here shows the largest Bitcoin mining pools measured by network hash rate as of April 2021.
The chart is just a quick reference. The location of a pool does not matter all that much because most of them have servers in every country so even if the mining pool is based in China, you could connect to a server in the US or Europe, for example. Make sure you understand the pool’s fee structure (anywhere between 1% and 4%) before you commit.
If you are serious about joining a pool, the things you need is a mining rig (see above), a bitcoin wallet, and bitcoin mining software that also connects you to the pool. There is free open-source mining software like CGMiner. A critical issue for your profitability is the cost of electricity where you live (see mining calculator above).
Don’t confuse mining pools with cloud mining – something you really should stay away from. Cloud mining is where you pay a service provider to mine for you and you get the rewards. Cloud mining is a business arrangement where a miner owns all of the rig and infrastructure. You are effectively renting the hash power from the miner in exchange for potential profits in bitcoin.
The major problem with this arrangement is that you have no control over what they mine, when they mine, how they mine, or even if they have any infrastructure at all. And because of this, cloud mining attracts lots of scammers.
Check out our SmartWorlder section to read more about smart technologies.