You use credit cards every day, but you probably don’t know how credit card processing works. The same can be said for Bitcoin, although the more you understand about how Bitcoin works the more confident you can be safely storing and using your bitcoin.
At a high level, here’s how Bitcoin works:
- Any computer running Bitcoin software joins a peer-to-peer network of other computers running Bitcoin software. These connected computers are called nodes.
- Nodes can create, sign, verify and share bitcoin transaction information with one another.
- Each node also maintains a database (aka the blockchain) of every transaction that’s ever happened since the day Satoshi fired up his first node.
- New transactions are added to the blockchain in batches (aka blocks) every 10 minutes by one lucky node on the network via a lottery.
- Special mining nodes can create lottery tickets by attempting to guess a difficult number (aka mining).
- Mining isn’t free. Nodes burn a lot of electricity guessing this number and electricity (typically) costs money.
- When a miner guesses a winning number, it creates a new block by taking all the transactions it’s heard about since the last block and adding them to the blockchain.
- As a reward, the miner receives all the transaction fees included in the block + a special transaction called the block reward from no-one to themselves for 6.25 bitcoin.
- The miner broadcasts the block + the winning lottery number to all the other nodes on the network for verification.
- The nodes verify the miner’s winning number and if it’s correct, add the new block to their copy of the blockchain and move onto guessing the next number.
- This cycle continues roughly every 10 minutes for all of time…
Pretty cool right? Let’s dig a little deeper into some of these topics.
Nodes
At the time of writing this there are roughly 16k nodes on the Bitcoin network. There are two different types of Bitcoin nodes:
- Validating nodes – Create, sign, verify, share and store transaction information
- Mining nodes – Do everything a validating node does plus participate in the mining lottery
Maintaining a copy of every transaction that’s ever happened since 2009 is hard work and takes up a lot of hard drive space (500 gigabytes today), so most people interact with Bitcoin via an Simplified Payment Verification (SPV) client commonly referred to as a Bitcoin Wallet. Bitcoin wallets contain only your personal transaction history and interact with a Validating node which broadcasts transactions on the wallet’s behalf.
For example, a technically savvy or privacy focused user may use the Bitcoin software on their Validating node to transact or they may use a mobile Bitcoin wallet configured to communicate directly with their own “full node”. Most Bitcoin users don’t run a node at all, they simply download a Bitcoin wallet which communicates with the wallet provider’s node.
Transactions
Every Bitcoin transaction contains transactions of inputs and outputs:
- Inputs – previous transactions on the blockchain signed by my private key which add up to the amount being sent
- Outputs – new transactions containing addresses I want to send bitcoin to and the amount I want to send to each
For example, let’s say I want to send 1 BTC, and I have two previous transactions each containing 0.6 BTC, then my transaction will contain both 0.6 BTC transactions as inputs. As outputs, my transaction will contain one new transaction of 1 BTC to the recipient’s address and one transaction of 0.1999 back to my own address. The difference of 1.2BTC in minus 1.1999 BTC out is 0.0001 which is left for the miner as a transaction fee.
By including a small transaction fee, we incentivize miners to include our transaction in the next block.
Input | Output |
Transaction #1 = 0.6 BTC | Transaction #3 = 0.1999 BTC (back to me) |
Transaction #2 = 0.6 BTC | Transaction #4 = 1.0000 BTC (to recipient) |
Fee = 0.0001 (remainder left over for the miner) |
Blockchain
Finally you understand what a blockchain is! The Bitcoin blockchain is simply a database of past bitcoin transactions grouped into blocks. When a miner adds a new block, they include a hash of the block before it which “chains” the blocks together.
Not every transaction makes it into the blockchain. When nodes share transactions with each other, those transactions first sit in the node’s memory called the mempool. Satoshi set the maximum block size to 1 megabyte to prevent spam and ensure blocks can be easily shared between nodes. So if there are more than 1mb worth of transactions in the mempool, miners will include transactions with higher transaction fees and leave the rest.
This limited block space creates a “fee market” for including your transaction in a block. Roughly 2.5k transactions fit in each block when blocks are full, so if you want your transaction processed quickly you need to include a higher fee. Fee calculation is typically handled by your wallet but advanced users can set their fee manually.
Today, blocks are only full when Bitcoin is in full bull market mode, but as more people use Bitcoin the blocks may become permanently full which will cause fees to increase substantially and fee calculation to become more important.
Mining
Entire books have be written on the evolution of Bitcoin mining and how mining works, but the essential things to understand are that mining is:
- the blockchain’s censuses mechanism
- the blockchain’s security system
- the way new bitcoins are issued
Mining is the process by which nodes on the network come to an agreement with one another (aka consensus) about the state of the blockchain. The only way to win the mining lottery is to burn energy guessing the winning lottery number. So if you’ve got the winning number, that number is proof you put in the work guessing it. This is known as Proof of Work (PoW) and Bitcoin is said to have a Proof of Work consensus mechanism often referred to as Nakamoto Consensus as a hat tip to Satoshi.
If someone wanted to manipulate a transaction in a previous block on the blockchain, they would have to re-generate the Proof of Work for all the blocks leading up to that block. The further back a block, the more PoW needed to change it. This creates a “wall of security” protecting historical transactions in the blockchain from being tampered with.
Block Rewards
When a miner wins the lottery, they receive all the transaction fees in that block plus the block reward. Block rewards are the way new bitcoins are created and issued. Back when Satoshi launched Bitcoin and mined the first block, the block reward was 50 bitcoins per block. The block reward is programmed to cut in half every 210,000 blocks which is roughly every 4 years. The following charts shows the history of Bitcoin halving events:
Halving | Block Reward | Halving Date | Price |
1st Halving | 50 → 25 BTC | November 28th, 2012 | $12.35 |
2nd Halving | 25 → 12.5 BTC | July 9th, 2016 | $650.63 |
3rd Halving | 12.5 → 6.25 BTC | May 11th, 2020 | $8,759.28 |
4th Halving | 6.25 → 3.125 BTC | April 19th, 2024 | $63,500 |
5th Halving | 3.125 → 1.5625 BTC | 2028 | ? |
This “halving” event, sometimes called “The Halvening” just for fun, occurs every 210k blocks until the total bitcoin supply reaches 21 million, which is estimated to take place in the year 2140. After that, miners will no longer receive block rewards and transaction fees will be the only incentive remaining to secure the network.
Difficulty
We mentioned that new blocks are mined roughly every 10 minutes. 10 minutes is the target initially set by Satoshi, but in reality a miner might guess the number a lot sooner or take a lot longer based on how lucky or unlucky they are. The block time is also impacted by mining hardware becoming more efficient, more miners entering the lottery and old inefficient miners retiring.
In order to maintain the roughly 10 minute block times, Bitcoin software looks back every 2016 blocks at the average amount of time taken to mine the last 2106 blocks and increases or decreases the size of the number miners need to guess in order to win the lottery. This is known as the difficulty adjustment. The more competitive mining becomes, the more difficult it is to win the lottery.
The combination of concepts such as Proof of Work, Blockchain, Block Rewards and Difficulty Adjustments are what enable Bitcoin to be the first truly trustless and permissionless digital money. While small changes to the Bitcoin code continue to this day, core concepts such as these are fundamental to the way Bitcoin works and would never be adopted by the other nodes on the network.
Tick-Tock, onto the next block.