Truffle Introduction

Hey @BrendanGolledge

I used metamask once before this course and my experience with it was awful. I tried to buy some altcoins and found that the transaction fee was nearly $300.

This is not metamask, it’s Ethereum. At the moment the ethereum network is very congested therefore DEFI transactions are expensive.
In order to follow this course you don’t need to use the mainnet, you will use testnet instead. You will not need to spend any ether, just test ones.

Regards,
Dani

1 Like

got an error after installing everything and got to the point of doing truffle init


What it says:

truffle : File C:\Users\Logan\AppData\Roaming\npm\truffle.ps1 cannot be loaded. The file C:\Users\Logan\AppData\Roaming\npm\truffle.ps1 is not digitally signed. You cannot run this script
on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ truffle init
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Hello! Having some trouble -

I entered the command in terminal and got the following:

Marvins-MBP:~ bigboy$ npm install -g [email protected]

npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! code EACCES

npm ERR! syscall access

npm ERR! path /usr/local/lib/node_modules

npm ERR! errno -13

npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

npm ERR! [Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’] {

npm ERR! errno: -13,

npm ERR! code: ‘EACCES’,

npm ERR! syscall: ‘access’,

npm ERR! path: ‘/usr/local/lib/node_modules’

npm ERR! }

npm ERR!

npm ERR! The operation was rejected by your operating system.

npm ERR! It is likely you do not have the permissions to access this file as the current user

npm ERR!

npm ERR! If you believe this might be a permissions issue, please double-check the

npm ERR! permissions of the file and its containing directories, or try running

npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/bigboy/.npm/_logs/2021-03-02T22_16_47_429Z-debug.log

I tried the following :

sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

from https://www.willandskill.se/en/how-to-fix-eacces-errors-with-npm-on-macos/

but still no dice, please help!

Hi @Hogie

I looked in the forum as other student had the same message from PowerShell.
This seem to fix:

In a admin powershell run Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser to make the current user always able to run scripts else if you just want it to be able to run it for the current shell session you would the need to change the scope to Process instead of CurrentUser.
You can read more about it here
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

Regards,
Dani

Hi @mervxxgotti

Run sudo npm install -g truffle and you should be alright.
You will get a bunch of warnings but you can ignore them.
Once done, check if truffle is installed by trying truffle -v.

Regards,
Dani

1 Like

I’m here at Ethereum Smart Contract Programming 201 / Categories / Truffle Introduction / Setter Function. After adding the setter function, and run migrate --reset, Im getting this error:“TypeError: Cannot read property ‘imports’ of undefined”
Why? I just added a setter() function. It was ok in the getter()
HelloWorld:
pragma solidity 0.8.1;
.
.
truffle-config.js
compilers: {
solc: {
version: “0.8.1”,

I run this command : npm update -g truffle
then a new error message comes up :
Unknown network “ganache”. See your Truffle configuration file for available networks.

To solve this, I run these 3 commands:
npm uninstall -g truffle > npm install -g truffle > truffle init .

Is this the right way? bec I have to retype everything.

Hey @padlanau

You can just add the right settings to your truffle config so that it recognises Ganache.

Check out my suggestion to another student

Cheers,
Dani

it worked!! Thank you!!

1 Like

When I change my code and save on Atom, I’m not sure if it’s properly updating with Ganache?When I use >truffle console and the >migrate – reset I get this error:

Unknown network “ganache”. See your Truffle configuration file for available networks.

Is there some configuration I need to change?

Hey @mervxxgotti

Please check couple of posts above this one, I answered the same question to another student :slight_smile:
Check it out and tell me if it helps!

Happy coding,
Dani

1 Like

I sent a screenshot to u that my truffle was successful installed but it wasn’t I just checked it now it saying the term truffle isn’t recognize so I try to install it again it bring up error pls wat should i do

Here is a screenshot

I followed the instructions here as requested: Unit Testing in Truffle

as well as the uninstall and re-install of truffle and now i get the following report - is this an issue?

Thanks for the help!

Hi @beloved

Run PowerShell as admin an try again.

Hi @mervxxgotti

Seems installed correctly. Run truffle -v, if you get info back it’s installed.

Cheers,
Dani

@MrSeven
This means that you already declared this instance. If you type: instance and hit enter, it should return a list of all methods of the deployed contract. Note that you can also declare a new instance with let instance = await Helloworld.new()

I have done it I created a new folder using mkdir hello-blockchain and changed the directory to hello-blockchain and then installed it it was successful and I run truffle init and it work here are screenshots

The compiler version was upgrade here are the list of my compiler version
My question is which one will I input