Let's get started with building our blockchain project. The first thing we're going to do is open our terminal and create our blockchain directory by typing commands into the terminal, as seen in the following screenshot:
Let's begin by creating a folder called programs. Inside this folder, let's create a directory called blockchain. This directory is currently empty. Inside of this blockchain directory is where we're going to be doing all of our programming. We are going to be building our entire blockchain inside of this blockchain directory.
Now our blockchain directory is ready, and the first thing that we need to do is to add some folders and files into it. The first folder that we want to put into the directory will be called dev, so we want to make sure that we are inside of the blockchain directory, and then let's type the following command into the terminal:
mkdir dev
Inside this dev directory is where we are going to be doing most of our coding. This is where we're going to build our blockchain data structure and create our API to interact with our blockchain, test it, and fulfill other similar tasks. Next, inside this dev folder, let's create two files: blockchain.js and test.js. To do this, enter the following command:
cd dev
touch blockchain.js test.js
The touch term in the preceding command line will help us in creating the mentioned files. The blockchain.js file is where we will type our code to create the blockchain and the test.js file is where we will write code to test our blockchain.
Next, let's return back to our blockchain directory by typing the following command in the terminal:
cd ..
In the blockchain directory, let's run the following command to create the npm project:
npm init
After running the preceding command, you will get some options on your terminal. To set up the project, you can just press Enter through those options.
So, this is pretty much all we need to do in order to set up our project folder structure. Now, if you go to our blockchain directory and open it with a text editor such as Sublime or Atom (or whatever you would like), you will get to see the file structure, as seen in the following screenshot:
The blockchain directory consists of the dev folder that we just created. Inside the dev folder, we can observe our blockchain.js and test.js files. Also, when we run the npm init command, it creates the package.json file for us. This .json file will keep track of our project and any dependencies that we need, allowing us to run scripts. We'll be working more inside of this package.json file in further chapters, so you'll become more familiar with it as we progress through the book.