Skip to content

Latest commit

 

History

History
81 lines (61 loc) · 3.54 KB

01.md

File metadata and controls

81 lines (61 loc) · 3.54 KB
title actions requireLogin material
Getting set up
checkAnswer
hints
false
terminal
help commands
You should probably run `npm init -y` followed by `npm install ethersjs zksync`😉
npm init -y npm install ethers zksync
hint output
npm init -y
Wrote to /Users/andrei/Documents/cz-zksync-tutorial/package.json: { "name": "cz-zksync-tutorial", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
hint output
npm install ethers zksync
> [email protected] install /Users/andrei/Documents/cz-zksync-tutorial/node_modules/websocket > (node-gyp rebuild 2> builderror.log) || (exit 0) npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN [email protected] requires a peer of ethers@^4.0.46 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] No description npm WARN [email protected] No repository field. + [email protected] + [email protected] added 85 packages from 39 contributors and audited 85 packages in 21.313s 11 packages are looking for funding run `npm fund` for details found 0 vulnerabilities

Both Ethereum and zkSync “speak” a language called JSON-RPC that is not human-readable. Luckily, they provide libraries that hide all the complexity below the surface, so you only need to know a bit of JavaScript.

☞ If you are not comfortable with JavaScript, consider going through a tutorial elsewhere before starting this lesson.

Initialize your Node.js project

Each Node.js project must contain at least one package.json file, usually located in the root directory of your project. This file identifies the project and lists the packages your project depends on, making your build reproducible.

You can create a package.json file by using a text editor, but the quickest way is to run the npm init command and pass it the -y flag as follows:

npm init -y

What is the -y flag, you ask?

The -y flag specifies that you want to accept all the defaults npm suggests based on information extracted from the current directory.

Install dependencies

We assume that npm and node are installed on your computer, and now we want you to install ethers and zksync.

The syntax for installing a package using npm looks like this:

npm install <package-name>

Put It to the Test

  1. The first thing you would want to do is to initialize your new project and accept all the defaults. If you can't remember the syntax for doing this, check the example from above. But first, try to do it without peeking.

  2. Now, let's use the npm install command to install ethers and zksync.

Note: It shouldn't matter the order in which you specify the packages you want to install but, since our command-line interpreter is pretty basic, it won't consider the answer correct unless you're specifying ethers first.