Bitcoin & blockchain explained to my dog
Tags: Blockchain, Bitcoin, Tutorial, Ethereum, Technology

Let me introduce my dog, Byzantine. Byzantine is not your average dog: he is a smart dog. He is interested in new technologies, especially in connected bones and evil artificial red lasers built to dominate cats.

Once, Byzantine turned on the TV and watched a documentary about a new kind of currency named bitcoin. He didn’t understand much about what he saw. How could bitcoin help him buy more bones for his diner? What was this borkchain thing? Byzantine felt completely lost.

Seeing distress in his eyes, I gave him a big bone and put him on my knees. He started asking:

What is bitcoin?

Well, when I gave you this bone, you took it with your mouth and received it. Now, you have one more bone and I lost one. I just had to give you this bone and you just had to take it to finalize the transfer. No third party was involved in this exchange. This bone is now yours and you can give it to one of your dog friend. Your friend can also give it to one of their friends and so on. I don’t have any control on this bone anymore, unless you give it back to me.

Now, let’s imagine that I want to give you a digital bone. Digital bones don’t work like real bones : the problem is that I could make a digital copy of this bone and send it to someone else at the same time. I could send one to you, and send the exact same copy to the cat right after.

Byzantine doesn’t like this idea.

Consider bitcoins work like digital bones. Some smart guys invented a solution to avoid the problem of false digital copy, aka double-spending. This solution is named blockchain.

Tell me more about this blockchain.

The first property of the Blockchain is that it works like a ledger. Every transactions between people (or dogs) are tracked in this ledger. It works like an accounting book:

But … how will the blockchain help me avoiding the cat getting a copy of my bitcoins?

This problem is called the “double-spending problem”. Imagine I have one bitcoin on my account and I send it to you. Then, if I send one bitcoin to Felix the crypto cat, this transaction will be tracked on the ledger and considered illegal since I don’t have any bitcoin left on my account. You will be the only owner of this bitcoin. Note that I’m not forced to send you 1, 2, 3 or another whole number of bitcoins. I could send you 0.0001 bitcoin or 13.37 bitcoins.

A sigh of relief appears in Byzantine’s eyes.

But we need someone or something impartial to take care of this ledger. When the bitcoin blockchain was invented, the aim was to send bitcoin without a third party. Exactly the way I gave you this bone earlier. So that using the blockchain, giving a digital bone is the same thing as giving a real bone from hand to hand.

So who … who is taking care of this ledger and is writing the transactions?

All Blockchain members are called nodes and they possess the same copy of the blockchain. Anyone can become a node and participate in the bitcoin network : that’s why we say that the bitcoin blockchain is public. It’s the second property of the blockchain: it is distributed.

To answer your question, adding a transaction in the blockchain is only possible for some special nodes, called miners, and they need to reach a consensus.

Byzantine seems confused.

What is a consensus?

Imagine that you’re with your dog friends, Patty, Lisa, Max and Roberto. You are playing in the garden and start smelling the nice smell of a hot tasty pie cooling down on the windowsill of Ms. Ripple. All of you are interested by eating this pie, but you are all good dogs knowing that it’s wrong to eat it. At this exact moment, a flying cat with a cape falls from the sky, steals the pie, eats it, and flies away.

Byzantine is now confused and angry.

Ms. Ripple calls the police to find who stole the pie. You and your friends are the number one suspects. To find the culprit, Ms. Ripple suggests to centralize all dogs at the same spot and ask them what happened. This is not a good idea since dogs could cross cover each other during the police questioning by telling the same story if one of them was guilty.

The inspector, Mr. Nakamoto, wants to try a different approach : he asks every dog separately to tell him the story. Since every dog gives him the exact same story without consulting before, it means that their story is very likely to be true. There is no doubt now: the evil super cat did the crime.

Byzantine feels better.

This is exactly how a consensus is made: if the majority of miners says that a group of transactions is valid, a miner can add those new transactions in the ledger which results in creating a new block added at the end of the blockchain.

Bork … a block? What is a block?

The blockchain is a chain of blocks. At the beginning, the blockchain was created with only one block : the genesis block. Approximately every 10 minutes for the bitcoin blockchain, a miner adds new transactions creating an additional block to the chain.

Every block has these informations :

a timestamp which is the date the block added to the chain,

the new transactions that the miner received from the network,

the hashkey of the previous block, which is the reflexion of every previous transactions that happened before,

a nonce that is the secret key that miners have to find to add a new block.

What does it mean? If you want to watch every transactions that occurred before, you can find them in every previous blocks. It’s the blockchain’s third property : it is auditable.

What is a hashkey?

If some evil cat wanted to change a transaction that happened in the past, it would completely change the hashkey and the transaction wouldn’t be accepted by the network.

Byzantine really hates cats.

Which means that the blockchain has a fourth property : it is unchangeable.

What is a nonce? What about miners?

The nonce is a key that miners try to find with their computer. To add a new block to the blockchain, miners have to find a nonce that combines well with the hashkey of the previous block and the new transactions in the hash function. They cannot know before what this nonce is : the only solution is to try a lot before finding a good one. It means that the higher the computing power of a miner is, the higher the chances are that he finds a good nonce.

The miner that finds a good nonce is allowed to add a new block and earns new bitcoins on his account from the network as a reward. This process is called proof of work. Miners are the people that make the bitcoin blockchain live.

But the proof of work consumes a lot of energy, which is a big issue for our planet and for the future of the bitcoin blockchain. There are also other types of consensus, and other types of blockchain like Ethereum. I will tell you this story another day.

Byzantine has finished eat my bone. He seems happy and feels smarter.