Truffle and Node
If you skipped the Angular chapter, you need to do the following first:
- Inside your
truffle-practice
folder, create a new folder calledchapter5
Now, let's get started with Truffle and Node. First, create a new folder called truffle-node
.
Inside the truffle-node
folder, we need to initialize a Truffle project.
So, run the following command in your Terminal, while inside the truffle-node
folder:
truffle init
Your truffle-node
folder structure should now look like this:
. ├── contracts ├── migrations ├── test ├── truffle-config.js └── truffle.js
To "run" this Truffle project, we need to have a JavaScript file to run as well as a package.json
file that states our dependencies. To generate the package.json
file, simply run npm init
in your Terminal, while in the truffle-node
folder.
Now, our folder should have the package.json
file.
. ├── contracts ├── migrations ├── package.json ├── test ├── truffle-config.js └── truffle.js
Next, let's add web3
as a dependency of this project. To do this...