Setting up a Node project
Setting up a Node project for smart-contracts
To start a new project, create a directory for it:
Then we will initialize our node project inside the newly created folder:
This will create a package.json
file, which will evolve as your project grows, such as when installing dependencies with npm install
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: npx. 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.
In this guide, we will be going with using Hardhat.
Tracking with Version Control
Before you get coding, you should add version control software to your project to track changes.
By far, the most used tool is Git, often in conjunction with GitHub for hosting purposes. Indeed, you will find the full source code and history of all OpenZeppelin software in our GitHub repository.
If you’ve never used Git before, a good starting place is the Git Handbook.
Don’t commit secrets such as mnemonics, private keys and API keys to version control! Make sure you .gitignore
files with secrets.
Last updated