Build Blockchain Using Javascript: Course Layout
Build Blockchain Using Javascript: Course Layout
In this course we will build a complete, fully functional blockchain from scratch using JavaScript
programming language.
Course Layout:
1. Build blockchain data structure.
2. Accessing the blockchain through an API.
3. Building a decentralized blockchain network.
4. Synchronizing the network.
5. Build network consensus algorithm.
6. Block explorer for a blockchain.
Our blockchain will be able to perform POW, mine new blocks, create transactions, validate the
chain and other functionality.
The purpose of this course is to help you to understand how blockchain technology works by
building your own blockhain and decentralized network.
By the end of this course, we will have a complete and full fledged blockchain prototype that is
hosted on a decentralized network.
What is a Blockchain?
An Immutable, Distributed Ledger.
DEVELOPMENT SETUP:
1. Node.js and NPM Installation:
Download Node.js from the link provided below and follow the mentioned steps
https://nodejs.org/en/download/
The Node.js installer also includes the NPM package manager.
1. Once the installer finishes downloading, launch it. Open the downloads link in
your browser and click the file. Or, browse to the location where you have saved the
file and double-click it to launch.
2. The system will ask if you want to run the software – click Run.
4. On the next screen, review the license agreement. Click Next if you agree to the
terms and install the software.
5. The installer will prompt you for the installation location. Leave the default
location, unless you have a specific need to install it somewhere else – then click
Next.
6. The wizard will let you select components to include or remove from the
installation. Again, unless you have a specific need, accept the defaults by clicking
Next.
7. Finally, click the Install button to run the installer. When it finishes, click Finish.
https://www.youtube.com/watch?v=YDWUKWtVBqY
DIRECTORY STRUCTURE:
1. We need to create our blockchain directory. Inside this directory we are going to be doing all
of our programming.
2. Now in the next step, We are going to create a sub folder in this directory. You guys can give
any name to this sub folder.
3. Then, We will create two files in this sub folder.
blockchain. js
test.js
4. The directory structure will look like this.
5. Next we have to run one command from the terminal and make it a NPM project.
Note: You should be in the same directory and then enter this command “npm init” without
quotation mark.
We will get some options after this command you just need to press enter to setup our project and it
will create a package.json file for us. I’ll explain this file later.
SECTION ONE:
We are going to make our blockchain data structure by using a Constructor Function in JavaScript.
As I mention that we are going to give our blockchain certain functionalities, such as the ability
tocreate new blocks, ability to create transactions, ability to hash data and hash blocks, ability to do
proof of work ant many other functionalities.
There are two important concepts that we should understand first before moving forward.
1. JS Constructor Function
A constructor function is simply a function that creates an object and allows you to create
multiple objects or instances from a constructor function.
2. Protoype Object
You can also add properties and methods to a constructor function using a prototype.