Setting Up a Node Project

New software industries often start out with every project sharing the same technology stack. The Ethereum ecosystem is no exception, and the language of choice is JavaScript. All of the most used Ethereum libraries, including OpenZeppelin software, are written in JavaScript or one of its variants.

JavaScript code is traditionally run on a web browser as part of a website, but it can be also executed as a standalone process using Node.

This guide will help you get your Node development environment set up, which you’ll need to use the different OpenZeppelin tools and other third party products.

If you are already familiar with Node, npm and Git, feel free to skip this guide!

Installing Node

There are multiple ways to get Node on your machine: you can get it either via a package manager or by downloading the installer directly.

Once you’re done, run node --version on a terminal to check your installation: any version of the 10.x or 12.x line should be compatible with most Ethereum software.

$ node --version

Creating npm Packages

JavaScript software is often bundled in packages, which are distributed via the npm registry. A package is simply a directory that contains a file called package.json, describing the package’s name, version, content, and others.

All Node installations include a command-line client for the npm registry, which you’ll use while developing your own projects. To start a new project, create a directory for it and run:

$ npm init

Simple as that! Your newly created package.json file 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.

Some OpenZeppelin tools (like the CLI) are executables intended to be run using npx. Not including npx will cause errors due to the binary not being in the system path, so for clarity we’ll display the full command in our guides:

$ openzeppelin init
openzeppelin: command not found
$ npx openzeppelin init
Welcome to the OpenZeppelin SDK!
Make sure you are inside your project’s directory when running npx! Otherwise, it will download the full executable again just to run that command, which most of the time is not what you want.

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.