Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier.
Adding Truffle to your project
You'll need installed before we get started. And you can choose a preferred package management tool to begin with:
# To use truffle locally in your project, you must init a package.json file
$ npm init
# Install truffle and wallet-provider to your project
$ npm i -D truffle @truffle/hdwallet-provider
# Generate truffle configuation file and default folders
$ npm exec -- truffle init
# To use truffle locally in your project, you must init a package.json file
$ yarn init
# Install truffle and wallet-provider to your project
$ yarn add --dev truffle @truffle/hdwallet-provider
# Generate truffle configuation file and default folders
$ yarn truffle init
You can install global Truffle to your environment:
$ npm i -g truffle
Then, you can ignore npm exec -- or yarn commands before truffle
Setup Truffle config file
We are going to edit truffle-config.js. First, we uncomment this line to import @truffle/hdwallet-provider: