Skip to Content
Courses

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!

Last updated on