Ok… I don’t know why, but now it seems to work…
- I have uninstalled and installed everything again
- I’ve setup a user variable:
- allow scripts in PS:
Set-ExecutionPolicy unrestricted
best regard
daniel
Ok… I don’t know why, but now it seems to work…
Set-ExecutionPolicy unrestricted
best regard
daniel
I had a Pssecurityexeption error at writting truffle init. Solves with typing this command line
Set-ExecutionPolicy RemoteSigned
And hit enter, respond y
to any prompts that appear.
If atom wont recognize solidity language so you can have coloured text like in the course video try this. It happened to me and it is solved now.
Hello @fillip,
I’m getting error “Expected identifier” for the constructor() in the Migrations.sol
pragma solidity >=0.4.17 <0.6.0;
contract Migrations {
address public owner;
uint public last_completed_migration;
constructor() public {
owner = msg.sender;
}
modifier restricted() {
if (msg.sender == owner) _;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
Hello @filip
Kindly be informed that I did it work by creating new project and rewrite the contracts and now it compiled.
Best Regards,
Hey, I was having a problem when I try to migrate in truffle. I write in >> truffle migrate this is my result…
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'ganache'
> Network id: 5777
> Block gas limit: 0x6691b7
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: Error: Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0x2914d0064C5dcC6a6d9883423EaDE6DdB1c4bB26
* Balance: 0 wei
* Message: Returned error: sender doesn't have enough funds to send tx. The upfront cost is: 134439500000000000 and the sender's account only has: 0
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:96:1)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Truffle v5.0.42 (core: 5.0.42)
Node v12.16.2
basically when you first launch ganache(what a cool name eh) and pick quick start, it gives you 100 eth, but when you go into the settings and pick the project it, for some unknown reason, its defaults to 0.00 ETH. I was gonna post for help but realized if you first save the qanache block chain session(wtf do you call it?) then add your project, then youll still have the 100 eth and you will be able to perform the migrate function successfully. Hope this helps someone.
@filip Hey, before I bring down an avalanche of questions Id like to let you know im learning a lot from you.
Now, the avalanche:
let instance = await Helloworld.deployed()
command to let blsdlkfj = await Helloworld.deployed
, will this mess up the migration process? I mean, we state let instance be called instance and write in the js file that the parameter is gonna be called instance but if we let it be called something else, would it work.Have a great day man.
@filip @ivga80 I am trying to resolve this error msg: Uncaught TypeError: instance.setMessage is not a function
pragma solidity 0.5.12;
contract Helloworld {
string message = "Hello World";
function getMessage() public view returns (string memory) {
return message;
}
//setter function
function setMessage(string memory newMessage) public {
message = newMessage;
}
}
@filip @ivga80 after I ran instance, for some reason it didn’t compiled the complete file:
source: ‘pragma solidity 0.5.12;\n’ +
‘\n’ +
‘contract Helloworld {\n’ +
’ string message = “Hello World”;\n’ +
‘\n’ +
’ function getMessage() public view returns (string memory) {\n’ +
’ return message;\n’ +
’ }\n’ +
‘}’,
sourcePath: ‘/Users/cherrybluemoon/truffle/contracts/Helloworld.sol’,
I’ve tried migrate reset, and same results…will keep you posted
@ivga80 @filip Do you know what might be causing the error Error: EACCES: permission denied
?
I cannot create a file or save using EOS Studio or ATOM. I cannot use truffle on command line. But when I use sudo truffle, then it works.
I have checked these:
cherrybluemoon@Markandrews-MacBook-Pro projects % node -v
v12.16.2
cherrybluemoon@Markandrews-MacBook-Pro projects % npm -v
6.14.4
cherrybluemoon@Markandrews-MacBook-Pro projects % ls -la /usr/local/lib/node_modules
total 0
drwxr-xr-x 5 cherrybluemoon wheel 160 Apr 15 17:08 .
drwxrwxr-x 17 cherrybluemoon admin 544 Apr 14 08:10 …
drwxr-xr-x 24 cherrybluemoon wheel 768 Apr 8 19:07 npm
drwxr-xr-x 13 cherrybluemoon wheel 416 Apr 15 17:08 truffle
drwxr-xr-x 7 cherrybluemoon wheel 224 Apr 15 12:08 truffle-soljs-updater
cherrybluemoon@Markandrews-MacBook-Pro projects % id -un
cherrybluemoon
I am stuck in the water…
Hi @creatiiive
instance and message in the helloworldtest.js are just variables, so you can call it the way you want.
let instance
can be let toto
it will just hold your contract object, so you can do
toto.getMessage()
it will works because toto now have all the methods of the contract object returned by the Helloworld.deployed() function.
toto.getMessage()
will return a string so you can also name it the way you want .
It doesn’t have to match the name you are using in your smart contract. This is two different program, so in your smartContract you can name it foo and in your helloWorldtest.js bar doesn’t really matter.
But it’s better to use the same variable name on both side to don’t get lost
You have a permission denied because you installed truffle as root, can you run:
npm root -g
to check where are the files installed by npm
If you have a permission denied when you try to save a file try to save your file in an other directory. In which directory are you try to save your files ?
For you truffle issue, try to remove truffle package with sudo.
sudo npm remove truffle
Then install it again without sudo, and install it locally (in your project directory).
npm -i truffle --save
Did you solve your issue with the setMessage() function ?
Hi,
I followed your steps.
My files are saved in /Users/cherrybluemoon/projects
I tried saveas to another new created folder and did’t work. Also I cannot create a new file.
npm root -g
/Users/cherrybluemoon/.npm-global/lib/node_modules
So regarding your issue to save a file let’s try few things.
try
cd /Users/cherrybluemoon/
ls -la .
cd projects
echo 'test' > test.txt && cat test.txt
We will check the permission of this folder, and check if you can write on it.
If you can it mean that EOS studio or Atom have been installed with an other user
For truffle can you type
which truffle
To see where is it located, then do
ls -la
on the path given
okay. Here’s the results:
cherrybluemoon@Markandrews-MacBook-Pro projects % echo test > test.txt && cat test.txt
test
cherrybluemoon@Markandrews-MacBook-Pro projects % ls
build package-lock.json truffle-config.js
contracts test
migrations test.txt
cherrybluemoon@Markandrews-MacBook-Pro projects % which truffle
/usr/local/bin/truffle
cherrybluemoon@Markandrews-MacBook-Pro projects % ls -la
total 48
drwxr-xr-x 11 cherrybluemoon staff 352 Apr 16 14:45 .
drwxr-xr-x+ 50 cherrybluemoon staff 1600 Apr 16 13:58 …
-rw-r–r--@ 1 cherrybluemoon staff 6148 Apr 16 08:33 .DS_Store
-rw-r–r-- 1 cherrybluemoon staff 0 Apr 15 20:17 .eosproj
drwxr-xr-x 3 root staff 96 Apr 16 07:55 build
drwxr-xr-x 3 root staff 96 Apr 15 17:27 contracts
drwxr-xr-x 3 root staff 96 Apr 15 17:27 migrations
-rw-r–r-- 1 cherrybluemoon staff 27 Apr 16 13:47 package-lock.json
drwxr-xr-x 2 root staff 64 Apr 15 17:27 test
-rw-r–r-- 1 cherrybluemoon staff 5 Apr 16 14:45 test.txt
-rw-r–r-- 1 root staff 4235 Apr 15 17:27 truffle-config.js
I can see now “root”
Hum the orders of my last command had importance, i wanted to see the permission on the projects folder
cd /Users/cherrybluemoon/
ls -la .
But it’s ok you did it a the end
ok so let’s do that
cd /Users/cherrybluemoon/
sudo chown -R cherrybluemoon:staff projects
it ll change the ownership of all the files under the projects directory to your user
EDIT: Now the problem is truffle is run by root so everything truffle will create will be own by root
Can you do this
ls -l /usr/local/bin/truffle |grep truffle
That was it! Thank you much appreciated
Show me the output of this command please
ls -l /usr/local/bin/truffle |grep truffle
eheh, because if it s still own by root you need to change the permission also on truffle
sudo chown cherrybluemoon:staff /usr/local/bin/truffle
It’s a bit dirty but it should work and it ll be faster than restart from the beginning
Here’s the output lrwxr-xr-x 1 cherrybluemoon admin 48 Apr 15 17:08 /usr/local/bin/truffle -> …/lib/node_modules/truffle/build/cli.bundled.js
Ok @cherrybluemoon it should be ok now , let me know if you have another issue by private message.