Setting up a Node project

Setting up a Node project for smart-contracts

To start a new project, create a directory for it:

mkdir learn_sc && cd learn_sc

Then we will initialize our node project inside the newly created folder:

npm init -y

This will create a package.json file, which will evolve as your project grows, such as when installing dependencies with npm install

circle-info

JavaScript and npm are some of the most used software tools in the world: if you’re ever in doubt, you’ll find plenty of information about them online.

Using npx

There are two broads type of packages stored in the npm registry: libraries and executables. Installed libraries are used like any other piece of JavaScript code, but executables are special.

A third binary was included when installing node: npxarrow-up-right. This is used to run executables installed locally in your project.

For our local blockchain development, we will need to install certain packages/libraries so that we can create a local blockchain network within our local systems. For this we can either Truffle or Hardhat.

circle-info

Whilst Trufflearrow-up-right and Hardhatarrow-up-right can be installed globally we recommend installing them locally in each project so that you can control the version on a project-by-project basis.

In this guide, we will be going with using Hardhat.

Tracking with Version Control

Before you get coding, you should add version control softwarearrow-up-right to your project to track changes.

By far, the most used tool is Gitarrow-up-right, often in conjunction with GitHubarrow-up-right for hosting purposes. Indeed, you will find the full source code and history of all OpenZeppelin software in our GitHub repositoryarrow-up-right.

circle-info

If you’ve never used Git before, a good starting place is the Git Handbookarrow-up-right.

circle-exclamation

Last updated

Was this helpful?