Setting up the Truffle project

We learned about Truffle in Chapter 5, Using Ganache and the Truffle Framework. To set up a new Truffle project, we have to do the following:

  1. Execute the following command in an empty folder:
$ truffle init

This will initialize the Truffle project-related files and folders under the current directory.

  1. Initialize the npm packages in the Truffle project. To enable the project to install npm packages, you will need to execute the following command:
$ npm init

The command will ask for certain details related to your package that you can provide, and it will create a package.json file under the current folder.

  1. Next, we need to install the dependencies of the project that we are going to use. As we have designed the contract's architecture, looking at that, we would need libraries from OpenZeppelin.

To install the latest version of the OpenZeppelin libraries, execute the following command:

$ npm install openzeppelin-solidity

The preceding command will install the OpenZeppelin package under the node_modules folder. You can check the version of the OpenZeppelin package installed in the package.json file. You can also change the version to use in this file.

By setting up the Truffle project, it has created a truffle-config.js file. We would need to check and update the configuration according to our needs. Now, let's update the configuration.

It is recommended that the latest version of OpenZeppelin libraries should be used. Also, developers should keep checking the recent issues fixed in the latest versions of OpenZeppelin.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.128.39