Book Image

Learn Blockchain Programming with JavaScript

By : Eric Traub
Book Image

Learn Blockchain Programming with JavaScript

By: Eric Traub

Overview of this book

Learn Blockchain Programming with JavaScript begins by giving you a clear understanding of what blockchain technology is. You’ll then set up an environment to build your very own blockchain and you’ll add various functionalities to it. By adding functionalities to your blockchain such as the ability to mine new blocks, create transactions, and secure your blockchain through a proof-of-work you’ll gain an in-depth understanding of how blockchain technology functions. As you make your way through the chapters, you’ll learn how to build an API server to interact with your blockchain and how to host your blockchain on a decentralized network. You’ll also build a consensus algorithm and use it to verify data and keep the entire blockchain network synchronized. In the concluding chapters, you’ll finish building your blockchain prototype and gain a thorough understanding of why blockchain technology is so secure and valuable. By the end of this book, you'll understand how decentralized blockchain networks function and why decentralization is such an important feature for securing a blockchain.
Table of Contents (10 chapters)

What is a blockchain?

In this section, let's go through a brief explanation of what a blockchain is. Simply put, a blockchain is an immutable, distributed ledger. Now, these words may seem quite complex, but when we try to break them down, it is very easy to understand them. Let's begin by exploring what a ledger actually is. A ledger is simply a collection of financial accounts or transactions (or in other words, a record of transactions that people have made).

Let's take a look at the following example to get a better understanding of ledgers. In this example, Kim paid Joe $30 and Kevin paid Jen $80. A ledger is simply a document that is used to keep track of these transactions. You can see this depicted in the following screenshot:

Now, what does it mean for a blockchain to be immutable? This means that it cannot be changedever. Consequently, when a transaction is recorded, it cannot be undone. Other factors that cannot be changed include the amount of money that was sent or the people who took part in the transaction. Once a transaction is made, no aspects of that transaction can be changed because it is immutable.

In the world today, we see many applications, platforms, and networks that are all centralized. Take Facebook, for example. Everyone who uses Facebook has to trust this company is protecting their data and not abusing it. Compared to this, blockchain is different. Blockchain technology is not centralized like Facebook, Google, or most other entities. Instead, it is a distributed network, which means that any given blockchain network is not controlled by a single entity, but is run by normal, everyday people. Blockchains, such as Bitcoin, are supported and hosted by thousands of people worldwide. Consequently, all of our data, or the ledger in this case, is not at the mercy of a single company or entity. This proves to be a great benefit of blockchain technology because by being distributed, we do not have to trust a single company with our data. Instead, our data is persisted by the entire network of thousands of different people who are all acting independently.

Each individual who contributes to the blockchain network is called a node, and each node has the exact same copy of the ledger. Therefore, the ledger data is hosted and synchronized across the entire network.

So, a blockchain is an immutable distributed ledger. This means that it is a ledger in which the transactions can never be changed and the blockchain itself is distributed across the network and run by thousands of independent people, groups, or nodes.

The blockchain is a very powerful technology which is still in its infancy, but its future is very exciting. There are many ways that blockchain technology can be applied to our world today to make certain industries more secure, efficient, and trustworthy. Some industries that could be transformed with the help of blockchain technology include financial services, healthcare, credit, governments, energy industries, and many others. Pretty much every industry out there could benefit from a more secure, distributed form of data management. You can observe that blockchain technology is at a very exciting stage right now, and many people are excited about what the future holds for it.

Now that we're aware of what blockchain is, let's move onto setting up our project environment to build our blockchain.