With the current coverage of Bitcoin in the media, I’ve had some friends tell me that they have no idea how Bitcoin works, so I thought I would try to give a bit of an explanation.
This is just a basic description of the basics of how Bitcoin works, intended for completely non-technical people - something that my grandmother might hopefully understand.
What is Bitcoin?
Bitcoin is a digital currency. That means it lives completely on computers - there is no cash form. It is also a distributed digital currency, which means that there is no single location, person, computer, or other system that controls the currency - the control is “distributed” across a large number of unrelated computers, which are run by a large number of unrelated people. This means that nobody (government or otherwise) can cause inflation by deciding to print money, and nobody can hack a single database to steal money. There are many websites around that discuss the benefits and problems with cryptocurrencies like Bitcoin; here I am only looking to explain how it works.
How does it work, technically?
Imagine a large list of transactions that includes all of the transactions that have ever occurred in an economy. For a small world of 4 people, it could look like this:
Transactions: |
---|
Alex receives $100 (new money) |
Beatrice receives $72 (new money) |
Transfer $40 from Alex to Clare |
Transfer $13 from Beatrice to Dinesh |
Transfer $11 from Dinesh to Alex |
Transfer $4 from Clare to Barnaby |
With this list we have all the information we need in order to know how much money everyone has:
- Alex has $71
- Beatrice has $63
- Clare has $36
- Dinesh has $2
This is exactly how Bitcoin works: there is indeed a huge list of transactions (called a “ledger”), and from all these transactions it is possible to have a complete picture of how many coins each person has. The first two lines above pay Alex and Beatrice from nowhere: in Bitcoin this is known as “mining”, which I will cover later.
Above I mentioned that Bitcoin is “distributed” - it is described this way because tens of thousands of people keep their own copy of this ledger. It is also described as operating on a consensus basis, because everyone needs to agree on how much money everyone has. As long as everyone has the same transactions in their copy of the ledger, then there should be no problem. So how does everyone keep their ledger up-to-date?
Computers in the Bitcoin network are constantly sending each other updates. Each computer is connected to several other computers, and they all pass on messages like a giant gossip system, so that eventually all of the computers will have heard about any new transactions. Each computer checks every update that it receives to make sure that it is valid.
Now that we have a way for everyone to keep up to date with what transactions are happening, the next problem is how to decide if a transaction is valid. For example, let’s say that I (Alex) have a balance of B100. Now, through the gossip I mentioned above, your computer hears about the following transactions:
Transactions: |
---|
Transfer B70 from Alex to Beatrice |
Transfer B80 from Alex to Clare |
Those transactions can’t both be valid - if both were to occur, then I would be left with a balance of -B50; there’s no such thing as an overdraft in Bitcoin, so these two transactions can’t both happen. So what should you do?
Maybe you could just take them in the order you received them? In that case, Beatrice would get B70 and you would reject the transfer to Clare. That would be fair, but the problem is that the whole system is based on everyone agreeing: not everyone would have received these transactions in the same order, so they wouldn’t all agree on which one to accept and which to reject. Now some people think I’ve sent money to Clare, while others think I’ve sent money to Beatrice, which means there is no agreement about who has what money. What we need is a way to enforce the order of transactions.
One way to order things is to mark each item with which other item comes before it in the list. For example:
Transactions: |
---|
… |
Transfer B100 from Dinesh to Clare (comes after B50 from Alex to Dinesh) |
Transfer B40 from Dinesh to Ebeneza (comes after B100 from Dinesh to Clare) |
Transfer B12 from Beatrice to Dinesh (comes after B40 from Dinesh to Ebeneza) |
… |
OK, now we have an order for our transactions. But there’s still nothing stopping me making both of those transactions like this:
Transactions: |
---|
Transfer B70 from Alex to Beatrice (comes after B12 from Beatrice to Dinesh) |
Transfer B80 from Alex to Clare (comes after B12 from Beatrice to Dinesh) |
Only one of them can be the next transaction, so how do you decide which one it is?
One possibility is to hold onto both of them, and just see what happens. Eventually you will receive some more transactions, which might look like this:
Transactions: |
---|
Transfer B72 from Clare to Ebeneza (comes after B80 from Alex to Clare) |
Transfer B9 from Clare to Dinesh (comes after B72 from Clare to Ebeneza) |
Transfer B17 from Beatrice to Dinesh (comes after B70 from Alex to Beatrice) |
Transfer B93 from Ebenza to Clare (comes after B9 from Clare to Dinesh) |
If you look at these carefully, you will see that one transaction claims to come after my transfer to Beatrice (the third one), while the other three are in a chain after my transfer to Clare. If everybody agrees that the longest chain of transactions is the valid one, then you can now decide that my transfer to Beatrice was invalid and reject it, keeping the transfer to Clare.
This is a good start, and it illustrates one of the key points of how Bitcoin works: it relies on everybody agreeing on a set of rules. In this example we have all agreed that the longest chain of transactions is the valid one, but we could just as easily have decided that the largest value transaction is the valid one if there is a conflict. The important part is that everyone agrees.
Now, you may have noticed a big limitation in our system so far. Every time you want to make a transaction you need to figure out which is the latest one so that you can write it on your new transaction. So many things could go wrong here! Maybe you haven’t yet heard about a new transaction from the other side of the network; maybe someone else is also making a transaction at the same time as you; maybe the last transactions you’ve seen are those two conflicting ones that I sent and you don’t know which one to pick. As I write this, there are 3 to 4 Bitcoin transactions happening per second - how could anyone be expected to correctly decide which transaction to place theirs after?
The answer to this is to bundle transactions together into blocks. Now we can have:
Block 39 (comes after Block 38) |
---|
Transfer B12 from Ebeneza to Beatrice |
Transfer B29 from Alex to Beatrice |
Transfer B33 from Clare to Ebeneza |
Transfer B41 from Ebeneza to Dinesh |
… |
Block 40 (comes after Block 39) |
---|
Transfer B92 from Francesca to Beatrice |
Transfer B83 from Beatrice to Clare |
Transfer B77 from Dinesh to Alex |
Transfer B60 from Alex to Dinesh |
… |
Block 41 (comes after Block 40) |
---|
… |
Here, instead of the transactions linking to each other, only the blocks need to link from one to the next (like a chain - this is where we get the term blockchain), and the transactions return to being a simple transfer of value. There are many transactions in a block (there tend to be between 1500 and 3000 transactions in a Bitcoin block) which means blocks don’t appear anywhere near as frequently - the time between blocks is about 10 minutes on average. That gives much more time for the latest block to get sent around (by that gossip system I mentioned earlier), so you are much more likely to have the latest block on your computer.
But who decides which transactions go into a block? This is the part where we finally get to the promised explanation of mining! When you want to send someone some Bitcoin, you create a transaction and send it out to the other computers on the network, like before. But this time, the transaction doesn’t “happen” straight away - it just goes into a big pool of transactions that people want to make, and is in a kind of “pending” state. From this pool, someone grabs a big bunch of transactions, checks that they are all valid (rejecting any that aren’t), bundles them together into a block (which says which other block it is supposed to come after), and sends that block out to the network. If your transaction got into the block, congratulations! Your transaction is now in the blockchain.
But who is that someone that grabbed the bunch of transactions and put them into a block? Well, actually, anyone can make a block! This introduces our next problem. Let’s say there’s a block like this:
Block 713 Previous block: 712 Time: 22/08/2020 11:36 |
---|
… |
Transfer B19 from Alex to Beatrice |
Transfer B100 from Clare to Dinesh |
… |
Clare is sending that B100 because she has sold it to Dinesh, maybe for $1000. Dinesh sees the transaction in the blockchain and gives Clare $1000, and everybody is happy and walks away. But since anyone can make a block, including Clare, what is to stop her going back through the blockchain and making a new block that looks like this:
Block 713 Previous block: 712 Time: 22/08/2020 11:36 |
---|
… |
Transfer B19 from Alex to Beatrice |
… |
so that her transaction is no longer there? With that transaction erased from the record, it never happened, so she still has both the B100 and the $1000!
The answer to this problem is that blocks are actually very difficult to make and it takes a lot of time and computing power to make one. Also, since blocks are chained together, it is not enough to just change one block - all blocks created since that block also need to be remade, otherwise the newly changed block won’t be on the longest chain and will be ignored:
If it requires a lot of effort to create a block, why would anyone choose to make one? The solution is to pay people to do it! They are paid in Bitcoin, of course. And this is where bitcoins come from in the first place - in every block, a certain number of Bitcoins are conjured out of thin air and paid to the person who made the block. This is where we get the term mining: someone does some hard work and gets a valuable reward for it (in this case it is their computer that does the hard work, but the idea still fits).
Since there’s money to be made by mining a block, naturally there are many people doing it! The process of creating a block involves finding a secret number that makes the block valid. I won’t go into the details of how this works, but the number is impossible to predict so miners have to just keep trying new numbers until they find one that works. In some ways it is a lot like opening doors to find which one has a prize behind it - you just have to keep trying more doors until you find the prize, or someone else beats you to it. The faster you can open doors (the faster your computer is), the better the chance that you’ll be the one to find the prize (and mine the block), but there’s never a guarantee. Once someone mines a block, they send it out to everyone else; once everyone has checked that it is valid, the miners then grab a new bunch of transactions from the pool and start trying to mine the next block.
So what we end up with is:
- many different people keeping their own copy of the ledger of transactions
- the ledger of transactions stored in “blocks”, which are chained together into a “blockchain”
- “miners” racing to create new blocks of transactions to add to the blockchain
- a complete public record of every transaction that has ever occurred
Extra details
You may have heard that Bitcoin is anonymous, and are thinking that all these transactions that I’ve shown are looking awfully non-anonymous. The reason is simple - I’ve just used names to make the explanation clearer. In reality, you send Bitcoins to an address, which is a bit like a bank account number except you don’t need to apply for one. With Bitcoin, you just make up your own!
To be a little more specific, you invent your own private key (which is a bit like a password - don’t ever give it to anyone, because anyone with it can spend your Bitcoins), and the Bitcoin rules then describe how to convert that private key into an address. The conversion only works in one direction, so it’s impossible to figure out someone’s private key from their address. Then you give your address to anyone that wants to send you Bitcoins, and they can send you some.
This might sound like a disaster waiting to happen, since I could accidentally pick the same private key as you, then spend all of your Bitcoins. However, there are 1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,976 different addresses, so the likelihood of us picking the same one is so tiny that it is nearly impossible.
I’ll try to illustrate the sheer size of this number: Imagine every grain of sand on every beach and in every desert of the world. Now imagine that each of those grains of sand is a miniature copy of our Earth, complete with beaches and deserts. Now imagine that every grain of sand on every beach and in every desert of all of those miniature Earths is itself a miniature copy of Earth. There are enough addresses for all 7.5 billion people on all of these second grain-of-sand worlds on all of the grain-of-sand worlds to have several addresses each. There are a lot of addresses.
How does it work, economically?
Another question I have been asked a few times is “How does Bitcoin have any value?”
Consider gold. While gold is certainly used for real purposes (mostly jewellery and electronics), most of the trade volume is for store-of-value, i.e., people buying gold without any intention of using it for something, only intending to sell it again at a later date. In that sense, gold’s value comes largely from a basic shared understanding and agreement that it has value - this was even enshrined in law in many places with the “gold standard” for many years.
Similarly, while Bitcoin can be used to purchase real products and services, it derives a lot of its value purely from people’s understanding that it will still be worth something in the future. Many people buy it in the hope that its value will increase dramatically like it has done in the past, while others buy it as a hedge against money-printing policies, both of which are very similar to gold-buying.
There have been quite a few things that can be bought with Bitcoin since it was created in 2009, including:
- Pizza
- Hotel rooms
- Video games
- TV & internet
- Burger King
- Funerals
- Guns
- Rolex watches
- Real estate
- Cars
- And gold!
Bitcoin doesn’t have the same market size, demand, or history as gold, so its price is a lot more unstable, but it will become more stable if it becomes more popular and accepted. Also, while it was originally envisioned as a cash-like currency (lots of small payments), the slow transaction speed and increasing transaction costs means that it is mostly being used for large, infrequent transactions - that is, as a store of value like gold. However, there are many other cryptocurrencies (hundreds of them!) that are looking to fill that gap and serve other purposes. Some of the larger ones include Ethereum, Litecoin, Ripple, and Tether.