Before diving instantly into the technical part, which will be covered in Chapter 2, *A Technical Dive into Blockchain*, you should first have an overview of what a blockchain is. If you have already read or heard about the topic, you might have figured out that it is appropriate for any use case relying on trust being ensured by a third party and where value is exchanged between different stakeholders. With the help of a simple example taken from an imaginary situation, the following sections will hopefully unravel the things you might have been confused about and the things you are eager to understand.

# Understanding blockchains

# Using centralized ledger systems

Imagine a village of 20 people living on an island in the middle of the ocean, without connection to any other tribes or countries. We will call this village, Village Alpha. They live a peaceful life in a resourceful environment where no one lacks anything.

Question: *How do the people of Village Alpha exchange and trade goods and services between each other?*

Avoiding the downsides of bartering, they invent a gold-minted coin, a form of money similar to a dollar bill in today's economy. Because this coin is portable and easy to identify and has a value in the eyes of all of the villagers, it quickly becomes the principal means of payment within the community. To ensure proper trade between each other, they record every exchange in a ledger and appoint one of them as the referring bookkeeper to maintain its accuracy and authenticity. The appointed bookkeeper is rewarded for his/her integrity and honesty by collecting a fee on every transaction.

And that's it! People can buy and sell goods with their gold-minted coins. The truth is ensured by the bookkeeper who keeps the ledger up to date, incentivized to behave fairly by levying fees on transactions. Anyone can challenge him/her by checking the transactions to ascertain proper recording.

The villagers found a solution to their problem, unknowingly inventing the banking system that prevails nowadays.

Now, let's assume that the bookkeeper is dishonest. Imagine he/she modifies the ledger during the night and erases some transactions or adds new ones? What if he/she destroys the ledger?

You can see that this system has its shortcomings. The villagers are currently using what we call a centralized payment system where everyone relies on the bookkeeper to ensure the truth.

In our modern society, the bank plays the role of the bookkeeper. When you send money to a friend, you trust the bank to carry out the correct fund transfers

This has major downsides:

- A single point of failure: Imagine a storm wipes out the village and the ledger with it.
- A trusted third party that can be dishonest: Imagine the bookkeeper modifies the transactions.
- A double-spending problem, which, however, is not applicable in our example because we assume they exchange physical goods. If the villagers were exchanging digital value, double-spending would have been an issue in the way that they would need an infrastructure to prevent replication of the digital assets. In other words, they would need a means to prevent an asset to be spent twice. More on that later.

# The blockchain alternative

So, how does blockchain offer a powerful alternative to this traditional centralized payment system?

Let's take the village on the neighboring island to see how they proceeded from the initial problem of exchanging goods. This village, which we will call Village Beta, is also composed of 20 people.

Instead of electing one of them as the bookkeeper who will certify the truth and the history of transactions between them, they find another solution.

They create a book in which each page is designed as a spreadsheet with ten lines and three columns. The lines will be used to input transactions and the columns to input three pieces of information: the sender's address, the recipient's address, and the amount, as shown in the following diagram:

Then, they replicate the book 19 times and hand over one copy to each villager so that everyone possesses one book. Finally, they craft 10,000 coins that they call Villagecoin and distribute 10 to each one of them, leaving the remaining in a vault.

# Empowering the ledger

When someone wants to make a transaction, he or she has to go to the central place of the village and shout to everybody else what transaction he or she is willing to make. When hearing the transaction, the other villagers write it down on the first page of their book: Alice gives 2 Villagecoin to Bob, Chuck gives 5 Villagecoin to Dan, and so on. In this way, every transaction is recorded in everyone's book, as shown in the following diagram:

With this system, no one was entrusted to assert the accuracy of a central book but instead, everyone is responsible for their own book.

This organization allows two things:

**Transparency:**The villagers can check whether a villager has enough money. Since all of the transactions are recorded, it's easy to check that Alice cannot send 15 Villagecoin to Dan, since she was given 10 Villagecoin on the first day and then sent 2 Villagecoin to Bob. She has therefore, only 8 Villagecoin remaining.**A first level of security:**Since everyone should have the same book and history of transactions, if Alice came to falsify a transaction in her book, it would turn invalid because everyone else (the majority) has the correct transactions recorded. Alice would just end up with an incorrect book and would need to retrieve a valid copy from another villager.

In this example, the book is what we call a **database** (or **ledger**), where all transactions and value transfers are logged. The village is the **community** that empowers the ledger; it is a network infrastructure where the villagers are the following:

**The nodes and the miners**: They are the entities that validate the transactions and store the ledger (more on that later).- They are
**the users of the service**provided by the network. In this example, the service is the ability to use a decentralized means of payment (Villagecoin) to sell and purchase physical goods. It can be compared to Bitcoin.

So far, we have seen some quite interesting things. We already demonstrated the decentralization feature of the blockchain and how a database can be shared and track-recorded across a network without being altered.

Now comes the most important and hardest feature to understand: security.

# The security factor

As stated before, each page of the book is designed with 10 lines. So, *what happens when we get to transaction number #10*? We surely need to go to the next page. However, before doing so, the villagers must validate the transactions and seal the page.

To keep the transactions secured, the villagers decide that each page must be removed from the book and put away on a special wall that will display each page once it is completed. This way, the villagers will be sure that the transactions (hence, the pages) displayed on the wall are true, valid, and correct.

**blocks**that contain the transactions. We can compare the wall as the entire blockchain, where all of the validated pages are displayed (in other words, where the blocks are chained together). If one transaction is altered in a block, then all of the following transactions in the subsequent blocks become invalid.

Let's stick to the example to understand how it works.

# Processing the blockchain

The wall that displays the valid pages will not let any villager put his/her page on it. After a page is completed with 10 transactions recorded, only one villager gets to put his/her page on it. To do so, all of the villagers will have to compete to find the result of a mathematical problem.

Here is the **delicate part**** **that makes a blockchain immutable and unalterable.

There is a section on the wall that has two small screens that will display some information every time a page is completed:

- On
**Screen A**, a number is displayed that we will call*the reference number.* - On
**Screen B**, the date and time are displayed.

Under these two screens, there are two other screens where the villagers will input data:

- On
**Screen C**, the villagers will input the 10 transactions of the completed page. - On
**Screen D**, the villagers will input a random number we will call*number X*.

Finally, a final screen displays a rule that must be respected when solving the mathematical problem, as shown in the following diagram:

To keep this chapter's consistency and help you to understand everything, we will further define the rule, the reference number, and number X. Everything will make sense by the end of this chapter. For now, just move on with how pages are completed and displayed on the wall.

When page #1 is completed, all of the villagers gather before the wall to take notice of the information provided in the two first screens. In our example, we have the following:

- Screen A: Reference number: 0
- Screen B: Date and time: 2018/06/25, 03:25 PM

The rule given on the wall is as follows:

*"The output number to be found when solving the mathematical problem must start with two leading zeros."*

Do you remember that, for a page to be accepted on the wall, the villagers will have to solve a mathematical problem?

Well, this problem is set like this:

*Screen A's reference number* + *Screen B's date and time* + *Screen C's transactions of the page* + *Screen D's random number input by the villager* (*number X*) = *an output number following the rule given by the wall* (*a number that starts will two leading zeros*)

In this equation, we actually know four out of the five variables:

- Data from
**Screen A**(the reference number) is given by the wall:**0**. - Data from
**Screen B**(the date and time) is given by the wall:**2018/06/25**, 03:25 PM. - Data from
**Screen C**(the transactions) are to be filled by the villagers. They are written on the pages of their books. - Data from
**Screen D**(the rule) is given by the wall: The output number to be found when solving the mathematical problem must start with two leading zeros

The equation can be pictured like this:

Now, the hard part for the villagers is to find the correct number to enter on **Screen D** for the equation to return a number that respects the rule of the wall: a number starting with two leading zeros.

To help you to visualize the mathematical problem, it can roughly be represented like this:

For this equation, the answer would be easy because we know that we have to add the numbers together and *number X* to find an output lower than 10. Here, *number X* would be equal to 1 or 2:

However, in Village Beta, no one knows the wall's algorithm. No one knows the logic of it and how the problem should be computed. They will have to try a lot of different *number X* solutions to find the correct output.