Truffle Introduction

That still does not see to be working. I will keep messing around with it. Maybe it has something to do with the path and it is not seeing it. I don’t know. Thank you for trying to help! I appreciate it!

1 Like

Hi @gabba or @filip,

Everything is working well until setMessage. I followed instructions to a tea. I compiled, recompiled, and get the same error message stating that “setMessage is not a function”

Can you please help me understand why this is? Many thanks,

Li

@gaba @filip

Nevermind, I got it to work. I needed to “instance = await Helloworld.deployed()”, not “let instance…”

Thank you.

1 Like

Thank for reaching out.
Good Work!.
What i also see is the “s” in “setMessage” function is small but while calling via truffle you are using capital “S” as seen in the image “SetMessage”

1 Like

So I was having some issues getting the truffle command to work. I was getting very frustrated because it said it was downloading but for some reason the command was not working. But with the help of @Godel I was able to solve the issue!

It seems that when I ran npm config list
My prefix was off. Instead of being prefix = "/usr/local"
It had my user and just was all out of whack. It seems that because of this the truffle command was not running.

To fix this issue I ran a few lines of code:

  1. npm config set prefix ‘/usr/local’
    This will set the proper prefix for npm
  2. npm uninstall -g truffle
    This will uninstall truffle from the wrong place it was
  3. npm i -g truffle
    This will install truffle in the proper file once prefix is fixed.

I hope that this information helps some people some time if they are having a hard time being able to use truffle!

Thank you!

1 Like

I had problems getting to run Truffle on a Mac as installation stopped due to permission errors. After some Googling, this command worked for me:

sudo npm install --unsafe-perm -g truffle

2 Likes

Great to see you solve the issue with this command but it is not the best way to do it as you can clearly see the command says that it is giving unsafe permission globally.

You can try chown and chmod to change the ownership and permission respectively

2 Likes

@Taha

In the following code, how does the function “function(instance)” get passed the argument “instance”? I.e. how does the compiler know to use the “instance” that was created in the console as an argument if it is not explicitly passed?

module.exports = function(deployer) {
  deployer.deploy(Helloworld).then(function(instance){
  	instance.setMessage("Hello Again!").then(function(){
		instance.getMessage().then(function(message){
			console.log("Current message: " + message);
		});
	});
  });
}; 

What is the point of initializing or setting variables through the deploy file when they can just be initialized in the contract itself? I don’t really get it.

Hi, I had to close Ganache because it crashed and had to reopen it, and now when trying to follow the Payable Functions video I get an error when trying to deploy.

This is the error I get after making the changes in that section:

1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------








Error: Error: Error:  *** Deployment Failed ***

"Migrations" -- Returned error: sender account not recognized.

    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:96:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)

@filip @Taha Please advise. Thank you.

Apologies for late reply

the instance of Hellworld is created and passed as argument to the function.
Deployer.deploy(Helloworld) is the instance and with the dot . the compiler knows to use the instance :slight_smile:

Hope this answers your question

1 Like

@CryptoBuddha
Can you elaborate this question?
As per what I understood: web3 need to initialize and set the variable and only then we can access them using web3 :slight_smile:

1 Like

@CryptoBuddha
Check the connection and account with Ganache and let me know.
I hope the truffle and ganache are in connected :slight_smile:

1 Like

How do I connect them? Or check for the connection?

console.log(web3) and console.log(web3.eth.accounts[0])
Check the syntax before copy the above commands :wink:

I tried both of those commands but still get the same error when trying to run “migrate --reset”. Please help!

I get:

Undefined
Undefined

When running the second command above.

This means you are not connected to Ganache
undefined means the variable value is NULL

Okay, but I thought you said those commands would connect Ganache. How do I connect to Ganache if the commands you said that connect to Ganache don’t work?

I’m sorry, I’m just starting to get really frustrated.