Crypto.com white logo

Win exclusive prizes in our FIFA World Cup™ trading competition.

How Does Bitcoin Work? A Deep Dive into Technical Aspects of BTC

Learn the mechanisms that make bitcoin work, including difficulty adjustment, the bitcoin supply curve, the bitcoin transactions mechanism, UTXO, Merkle Trees, hard and soft forks, and block explorers.

Jan 02, 2022

 

How are New Bitcoins Created?

Bitcoins are created through a process called ‘mining.’ Miners are required to solve a complex mathematical puzzle (called Proof-of-Work) before they are allowed to put new transactions into the blockchain. In return, they are rewarded with new bitcoins.

Anyone with a computer can become a miner with proper setup. Once you become a miner, you can jointly validate and record transactions with other miners.

Blocktime and Difficulty Adjustments

It is difficult to predict how many miners will join. If there are too few, the system will be too slow, resulting in poor user experience. If there are too many, the system will be too fast, resulting in security issues. Hence, it is important for the system to keep a relatively constant pace regardless of how many miners (in other words – hash power) are currently active.

Bitcoin uses a mechanism called ‘difficulty adjustment’ to keep the mining speed constant, at approximately 10 minutes per block. The ‘difficulty’ is adjusted every two weeks, taking into consideration the existing hash power in the past. If the hash power is insufficient (i.e. the average block time is longer than 10 minutes), the difficulty will be lowered. Conversely, if the hash power is too high (i.e. the average block time is faster than 10 minutes), the difficulty will be increased.

How are Difficulty Adjustments Determined?

Bitcoin’s protocol requires miners to compete with each other to solve a ‘cryptographic puzzle’ (called Proof-of-Work) so that the winner can propose a new block and append it to the blockchain.

The ‘cryptographic puzzle’ is solved by adjusting the nonce (a 32-bits arbitrary random number) so that the block-hash is smaller than the target-hash (a value that is smaller than 256-bits).

How does Bitcoin work image 1

Miners need to find a nonce, so that the hash of the block will be less than or equal to the target-hash specified by the network. If your hash is below the target, then you win and get the mining rewards. If not, you change the nonce and try again and again.

The more the hash power in the network, the smaller the target-hash. A smaller target-hash means that it’s harder for miners to find a correct nonce to create a block hash that is smaller than the target-hash. (Imagine the computer randomly picks a number between 1 and 100. The probability for finding a number below 10 is 0.1, but the probability for finding a number below 50 is 0.5).

This is how the bitcoin network performs ‘difficulty adjustments.’

What are Hash Rates, Mining Rewards, and Transaction Fees?

From the previous section, we see why hash power is important and how it is linked to blocktime and difficulty adjustment. Hash power can be measured by the hash rate:

Hash rate

The hash rate is a measure of the number of hash operations done in a given amount of time. This can vary depending on the hardware involved. For example, if a miner has a device that can generate a hash rate of 30 MhZ then there are 30 million hashes per second (a hash is one conversion from one state to another – or to simplify it further, one calculation).

So a GPU that yields a hash rate of 30MHz makes 30 million calculations per second.

Hash rate calculation

The higher the hash rate, the more likely that the miner will solve the block and gain a block reward. The probability of a miner solving the block can roughly be estimated by the following formula:

P = X / Y

Where:
P = the probability of solving a block
X = the miners hash rate
Y = the total hash rate of the network which is the total hash rate of all miners who are currently mining

You may have heard of mining farms which are huge industrial scale warehouses packed with mining equipment for the sole purpose of mining cryptocurrency. There may be thousands of GPUs (graphics processing units) linked up or ASICs (application specific integrated circuits) combined to make the overall hashing power far greater than that of just one solitary piece of mining hardware. This is designed to make it more likely that a block will be solved and a reward earned.

Mining rewards

Mining rewards are compensation (in the form of newly created coins) generated by the system to pay for the work done by miners when they have solved the cryptographic puzzle required for mining a new block.

The mining reward for bitcoin is currently 6.25 Bitcoin per block. Miners need to compete with each other in the network to race for the first place of having solved the block in order to receive the reward. Hence, the greater the hash rate, the higher the chance to receive the mining rewards. To improve the return on investment, mining companies and individuals often need to spend quite a bit up-front on hardware and electricity to increase the chance of successful mining.

However, with the drastic increase in the total hash rate of the bitcoin network, it becomes almost impossible for an individual alone to mine bitcoin due to limited resources. Mining pools therefore allow individuals to pool resources together and contribute to their out-sourced mining. This way, mining pools can gain more resources to compete against each other and individuals can share the rewards in proportion to their hash rate to mitigate the volatility they may face when mining alone.

Halving of mining rewards

Every 210,000 blocks the mining reward halves. Bitcoin started with a block reward of 50 BTC, then in 2012, 25 BTC, and in 2016, it halved again to 12.5 BTC. In 2020 the block reward halved again to 6.25 BTC and it will continue to halve until all 21 Million BTC are mined.

Different cryptocurrencies have different mining rewards and different token release schedules. This can be found by referring to the white papers of the respective cryptocurrency.

The block reward is collected in a coinbase transaction, which refers to the first transaction in a block. It is used by miners to collect the block reward or any additional transaction fees.

Transaction fees

Since mining rewards gradually decrease for Bitcoin and other coins that adopt the PoW mechanism, there is another type of incentive for the miners to verify transactions, called a network fee. For coins that work under the PoW consensus, users also need to pay a network fee to the miners for every transaction. This transaction fee may vary in different traffic conditions and for different coins. The transaction fee is the residual of the input left unspent. It is usually calculated in satoshi (the smallest unit of bitcoin) per byte.

Transaction fees are the incentives for the miners to verify your transaction. It is also possible to pay no or low transaction fees, but it will significantly lower the chance for the transaction to be included in the next block.

There are also some coins that have little or no transaction fee, and they usually apply a different consensus (e.g. DPoS, PBFT) or technology (e.g. DAG), some common examples are XRP, EOS, and IOTA.

Hard Forks and Soft Forks

A ‘fork’ in programming terms is an open-source code modification. Usually the forked code is similar to the original but with significant modifications, and the two ‘prongs’ comfortably co-exist.

Since cryptocurrencies are decentralised networks, all participants in the network – known as nodes – need to follow the same rules in order to work together properly11. That set of rules is known as a ‘protocol.’ Typical rules in a protocol include the size of a block on a blockchain, the rewards miners receive for mining a new block, and many more. The decentralised nature of blockchain means that nodes on the network must be able to come to an agreement as to the shared state of the blockchain.

The function of a fork

An unanimous protocol among the network nodes results in a single blockchain that contains verified data (transactions) that the network asserts to be correct. However, if nodes in the network exist that can’t come to an agreement on the state of the blockchain, that leads to a split into two branches. In the world of cryptocurrencies, a fork is more often used to implement a fundamental change or to create a new asset with similar (but not equal) characteristics as the original.12

There are two types of forks in crypto: soft forks and hard forks. But both kinds of forks fundamentally change how the protocol of a cryptocurrency works.

Hard forks

A hard fork is a radical change in a cryptocurrency protocol which is incompatible with the previous versions, meaning that nodes with the older protocol version won’t be able to process transactions or push new blocks to the blockchain. Any transaction on the forked (newer) chain will not be valid on the older chain. All nodes and miners will have to upgrade to the latest version of the protocol if they want to be on the new forked chain.

For instance, a protocol increases the block size limit from 2MB to 4MB. If an updated node tries to push a 3MB block to the blockchain, the older, non-updated nodes will not see this block as valid, and they will reject it. So as time goes on, two branches of the previous single blockchain form. One has both older and newer version blocks, and another has only the older version blocks. Which chain grows faster will depend on which nodes get the next blocks validated, and additional splits could follow. It is possible that the two (or more) chains could grow in parallel indefinitely.

How does Bitcoin work image 2 hard fork

Planned vs controversial forks

Depending on the situation, hard forks can either be planned or controversial.

For planned forks, nodes will voluntarily upgrade their software to follow the new rules, leaving the old version behind. The ones who don’t update are left mining on the old chain, which very few people will be using.

But if the fork is controversial, meaning that there’s a disagreement within the community about the upgrade. The protocol is usually forked into two incompatible blockchains – generating two different cryptocurrencies. Both of the blockchains will have their own community, and the developers will choose one that they believe is the best.

Since a new fork is based on the original blockchain, all transactions from the original blockchain are also copied into the new fork. For instance, if you have 100 coins of a cryptocurrency called Coin A, and a hard fork based on that cryptocurrency creates a new cryptocurrency called Coin B, you’ll also get 100 coins of Coin B.

Soft forks

A soft fork is a change in a cryptocurrency protocol which keeps it backward compatible. It means that non-updated nodes are still able to process transactions and push new blocks to the blockchain, so long as they don’t break the new protocol rules. This kind of fork requires only a majority of the miners upgrading to adjust to the new rules, as opposed to a hard fork which requires (almost) all nodes to upgrade and agree on the new version.

How does Bitcoin work image 3 soft fork

An example to demonstrate a soft fork is a new rule made to lower the block size limit from 3MB to 2MB. Older nodes will still be able to process transactions and push new blocks which are 2MB or less. But if an older node tries to push a block that is greater than 2MB to the network, newer nodes will reject the block because it violates the new rules. That encourages the older nodes to update to the new version since they aren’t as efficient as the updated ones.

Bitcoin’s Token Supply Explained

Bitcoin’s total supply is 21,000,0001. Currently there are more than 18,000,000 bitcoin mined already. Bitcoin’s first block reward was 50 BTC, and bitcoin block reward halving occurs every 210,000 blocks, so roughly every 4 years, significantly decreasing inflation. The current block reward is 6.25 BTC (after three halving events). The nextbBitcoin halving is expected to occur on 3 June, 2024. Some people predicted that all bitcoins will be mined a few years after 2100.

How does Bitcoin work image 4 bitcoin supply

Permanently lost bitcoin

Due to loss of private keys or hardware damage, some bitcoins are lost permanently3 and cannot be recovered, making the actual supply smaller than the theoretical value. The inventor of bitcoin, Satoshi Nakamoto, also has a considerable amount of bitcoin left untouched after mining it years ago.

For advice on how to keep your bitcoin safe from loss, check our article on the different crypto wallet options.

References

1. Turner, E., & Turner, E. (2013, November 11). The Rise and (Inevitable) Fall of Bitcoin. Retrieved from http://compoundingmyinterests.com/compounding-the-blog/tag/john maynard keynes.
2. Tatar, J. (2017). In Cryptoassets: The Innovative Investors Guide to Bitcoin and Beyond (p. 38). McGraw-Hill Education.
3. DuPont, Q. (2019). Cryptocurrencies and Blockchains. Polity Press.
4. B Palacio (2012, May 24), How a Bitcoin transaction works. Retrieved from https://visual.ly/community/infographic/technology/bitcoin-infographic
5. B Palacio (2012, May 24), How a Bitcoin transaction works. Retrieved from https://visual.ly/community/infographic/technology/bitcoin-infographic
6. Frankenfield, J. (2019, September 23). Block Reward. Retrieved from https://www.investopedia.com/terms/b/block-reward.asp
7. Transactions. (n.d.). Retrieved from https://bitcoin.org/en/transactions-guide#introduction
8. Shaan Ray (2019, October 14), Merkle Trees. Retrieved from https://hackernoon.com/merkle-trees-181cb4bc30b4
9. Andreas M. Antonopoulos (2014, December). Mastering Bitcoin. Retrieved from https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch07.html
10. Greg Walker (2016, March 25), Merkle Root, Retrieved from https://learnmeabitcoin.com/guide/merkle-root
11. Hard Forks and Soft Forks (2019, October 21). Retrieved from https://www.binance.vision/blockchain/hard-forks-and-soft-forks
12. Hard Fork vs Soft Fork (2018, March 16). Retrieved from https://www.coindesk.com/information/hard-fork-vs-soft-fork
13. Hard Forks and Soft Forks (2019, October 21). Retrieved from https://www.binance.vision/blockchain/hard-forks-and-soft-forks
14. BlockExplorer.com (2015, June 20). Retrieved from https://en.bitcoin.it/wiki/BlockExplorer.com

Tags

bitcoin

blocktime

crypto

difficulty adjustments

forks

hash rates

mining rewards

proof of work

token supply

transaction fees

Share with Friends

Ready to start your crypto journey?

Get your step-by-step guide to setting up an account with Crypto.com

By clicking the Get Started button you acknowledge having read the Privacy Notice of Crypto.com where we explain how we use and protect your personal data.
Get Crypto.com App

Common Keywords: 

Ethereum / Dogecoin / Dapp / Tokens