Truffle Initialization
Letās install Truffle and initialize a new project.
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:
-
Remove all contracts in the ā/contractsā folder, except the Migrations.sol file.
-
Remove all the tests in the ā/testsā folder.
-
Remove all migrations except the 01_intial_migration.js.
Now, letās get started with the solidity part!