Crypto and Coin

How does bitcoin work? (illustrated)

June 27, 2019

So you have been hearing about Bitcoin maybe even cryptocurrencies for a while. You have been browsing the web searching about it but none of the articles you read explained clearly enough how it works.

Bitcoin is a way of exchanging value over the internet without having a central authority validating transactions. It is difficult to grasp and very different from the money you are using every day.

With this article I will explain as simply as possible what Bitcoin is, introducing key concepts progressively and explaining them with simple terms and drawings.

Let’s start with what you are already used to.

How does my credit card work?

To understand how value is transferred with bitcoin, let’s start with a traditional banking system. When you use your debit or credit card to pay for something, your bank is going to check if you can spend that amount of money.

Bob asks the bank if he can withdraw money

The problem is that your ability to use your money depends on what the banking system allows you to do. If someone with enough authority wants to freeze your account for any reason, good or bad, you can’t use your money. That is because the banking system is centralized. It means any decision is in the hand of a central authority deciding if you are allowed to do something or not whether the reason is good (preventing crime) or not (not allowing a political opponent to access his funds).

Bob get his payment denied

How is Bitcoin different?

Multiple voices instead of one

Bitcoin is different. It’s a decentralized system. It’s constituted of multiple nodes over the internet. Each full node (we will cover nodes in detail in a different article) possesses the history of every transaction ever made on Bitcoin called a ledger!

Anyone can be a node of the Bitcoin network. It means that if you download the Bitcoin reference software for example (we will get to it later) and run it on your computer, then congratulation you became a node! It means your computer is playing a part in validating transactions on the Bitcoin network! Anyone can join the party without having to ask for permission to anyone. The Bitcoin network is permissionless!

The version of the software you use determines the set of rules you apply on your node. Bitcoin developers (people who create the reference Bitcoin software) can’t force an update on the network. Nodes decide the rule of the game! That’s another difference with other currencies and traditional banking: you don’t usually get to vote for the rules or take part in the transaction validation process. With Bitcoin, you can! We will discuss more about nodes in another article.

Bob is in front of the Bitcoin network

Only 3 nodes are represented but to this day there are around 10500 active nodes in the Bitcoin network!

Sending a transaction to the Bitcoin network

Let’s say Bob wants to send money to Alice. He creates a transaction. A transaction is like a check. You write who it’s going to and then instead of giving it to the recipient, you just hand it to the Bitcoin network. It will know whose money it is and to whom it must be given to. The network will even know if the transaction is valid (if money can be spent) because you signed it! Signing is not done with a paper and a pen in this case but with math and especially cryptography. We won’t cover the details here but just be aware that this allows you to prove you know a secret without actually revealing it.

Giving the check to the Bitcoin network is called broadcasting a transaction. You send it to one node of the network. It doesn’t matter which node actually, any node will do just fine!

When the transaction is given to one node it then broadcasts your transaction to other nodes. It’s called propagating a transaction. It’s how the Bitcoin network keeps every participant aware of everything. The transaction is in what we call the mempool.

Bob creates, sends and propagates a transaction

The mempool is some kind of waiting room where transactions are waiting. Waiting for what? Why can’t we just use these transactions right now? That’s what we will see next!

Sneaking a double-spending

Let’s say that instead of Bob wanting to send money to Alice, we’ve got Robby McRobbing whose firm intention is to profit from the Bitcoin system 😈… Robby will try what is called a double-spending. He will create not one but 2 transactions for the same Bitcoin. That would be the equivalent of writing two checks for money you have but once one check is cashed in, the second check has no funding. Once the 2 transactions are created, Robby sends it to 2 different nodes!

Robby McRobbing is up to something...

Each node will propagate the transactions to other nodes but there will be a problem once the 2 transactions reach the same node. Remember that the two transactions are valid (Robby is spending an existing coin) but only one of the two can exist. The second one would spend an already spent Bitcoin. A node will discard the second one it receives… But it depends on which one he received first! Now we’ve got half the nodes having one transaction and half the nodes having the other. Well done Robby, you messed things up!

Robby McRobbing did a double-spending!

That’s a problem because let’s say I want to check if Robby actually paid me. The answer depends on which node I ask. We don’t want that!

One ledger to rule them all

So we must find a solution so that Robby can’t mess up with money like this. Someone has to decide which valid transaction prevails over the other and tell it to the other nodes. Everyone has to be on the same page!

But wait, remember that we don’t have a central authority like banks. So who gets to decide which node is right or wrong at a given moment?

Let’s pick a node randomly and he will gets to decide what transaction is right and propagate it to the other nodes.

Why randomly? Because if it’s always the same person who gets to decide which transaction prevails over the others, you get in a situation where one person gets to decide who can spend money and who can’t. That would be the opposite of what Bitcoin wants to solve!

We also want the choosing of the “validator” to be unpredictable. If someone could predict who the next validator is, he could use that information to try to influence the validator into taking some transactions before the others or not include some transactions he is not interested in seeing validated.

The Bitcoin solution to this problem is to set a competitive game. The first one who’s got the solution to a given math problem owns the right to be the validator and decide which one of Robby’s transaction prevail over the other. Robby cannot double-spend and rob people anymore. Checkmate Robby!

The act of solving this math problem to own the right to be the validator is called mining.

The result of mining is a block containing several transactions (taken from the mempool) that is appended to the blockchain! The blockchain is the ledger of every Bitcoin transaction that ever happened (except those in the mempool). Every full node has a copy of the blockchain and can check at any time if everything is valid!

The miner saves the day!

Note: Not every node is a mining node. These are a special type of node doing very intensive calculations. Most of the time they are specialized hardware called ASICs. Without going into details, they are electronic cards specialized in solving the math challenge we spoke about: mining!

Conclusion

What have we seen so far?

  • Bitcoin is different from other payment systems because it relies on an open network of nodes instead of central authority.
  • A transaction is sent to the bitcoin network and propagated to other nodes
  • Mining is here to avoid double-spending without having a central authority in the process
  • The result of mining is a block of transactions appended to a structure called the blockchain
  • Every full node has a copy of the blockchain and contains all the Bitcoin transactions that ever happened!

Having a question or suggestion about the article?

Tell me on Twitter where I'm @vincentdnl!


Help others understand Bitcoin and cryptocurrencies by sharing this post!

LinkedIn
Reddit
WhatsApp