Skip to content

Truffle Initialization

Let's install Truffle and initialize a new project.

View the Full Course Now

Truffle Installation

Before we get started, let's make sure we have the latest version of truffle installed:

npm install -g truffle

Project Initialization

Then create a new folder, "cd" into it and unbox the react-box from truffle:

mkdir s06_tokenization

cd s06_tokenization

truffle unbox react
Having troubles?

If you are experiencing troubles with truffle and the error has things like "npm ERR! gyp info using node@16.3.0 | darwin | arm64" then have a look at your node version. Truffle has troubles with node version 16 - install node 14 instead.

If truffle installs fine, but you are experiencing troubles running truffle, because something with "remote signed execution policy" comes up in PowerShell then run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in a PowerShell window.

Another thing that can cause errors is directories with spaces. Make sure you are working from a directory without spaces

For anything else google the error message, it should bring you a solution, and if it doesn't reach out in the course Q&A, we're on standby to help out.

Running in WSL2?: One person solved it by first initializing a new project in the folder with npm init -y

Macbook (pro) M1 Users

Some people reported problems with Macbook M1 and Truffle developer console. Quote from one of the Students: "This program works only on node 10, 12 or 14. And in case you are lucky ones and got Macbook pro M1 then you wont be able to run 'Truffle developer or truffle develop' command with node 14. If you downgrade to node 12 and run 'truffle develop' command then you would get " wasm assemble issue ... memory over run error" ... so better you keep node 14.17.0 and run the program on Ganache ... as truffle support on node 14 version does not run the truffle develop command successfully."

And leave only the scaffolding for a blank new project:

  1. Remove all contracts in the "/contracts" folder, except the Migrations.sol file.

  2. Remove all the tests in the "/tests" folder.

  3. Remove all migrations except the 01_intial_migration.js.

Now, let's get started with the solidity part!