Hey @ArtCenter1
Try ganache-cli to make sure it is not an issue with your project.
Open the terminal and type:
truffle develop
migrate --reset
If it works try to reinstall ganache or use the cli version.
Cheers
Dani
Hey @ArtCenter1
Try ganache-cli to make sure it is not an issue with your project.
Open the terminal and type:
truffle develop
migrate --reset
If it works try to reinstall ganache or use the cli version.
Cheers
Dani
Hello Filip,
yet another setback while compiling my contract. I got this message
migration.sol file :
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;
modifier restricted() {
require(
msg.sender == owner,
“This function is restricted to the contract’s owner”
);
_;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
There is a typo in the first line, should be pragma
.
cheers
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;
modifier restricted() {
require(
msg.sender == owner,
“This function is restricted to the contract’s owner”
);
_;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;
modifier restricted() {
require(
msg.sender == owner,
“This function is restricted to the contract’s owner”
);
_;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
yes pragma , i miss paste it above .
at my atom editor pragma , looking forward to hearing from you soon
@filip Hello, I’m following along on a Mac computer, I got Truffle to install but truffle init is saying command not found. If there is a different syntax, where would I find this information?
this is the error :
Compiling .\contracts\helloworld.sol
Error: CompileError: /C/Users/مـــــــول/desktop/rodi/helloworld/contracts/helloworld.sol:11:2: ParserError: Expected pragma, import directive or contract/interface/library definition.
}S
^
Compilation failed. See above.
at Object.compile (C:\Users\مـــــــول\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\workflow-compile\legacy\index.js:72:1)
Truffle v5.0.42 (core: 5.0.42)
Node v14.15.0
PS C:\Users\مـــــــول\desktop\rodi\helloworld>
@dan-i @filip Hi guys, ran into a problem with the setter function that I can’t resolve - I copied Philip’s code for the deployment file, but for some reason the current message is not getting logged in the console.
Here’s the code I’m using:
const HelloWorld = artifacts.require("HelloWorld");
module.exports = function(deployer) {
deployer.deploy(HelloWorld).then(function(instance){ // instance here is the contract returned by deployer.deploy(HelloWorld) after it has deployed.
instance.setMessage("Hello Again!").then(function(){ // here we want to call getMessage only ofter setMessage changed the message.
instance.getMessage().then(function(message){ // Getmessage returns the message, so we can pass that to console.log
console.log("Current message: " + message)
});
});
});
};
Here’s my console after running migrate --reset:
https://gyazo.com/9bcdfbfb09c454721b44b89b943f8bfc
It seems like the deployment file sets the message to “Hello Again!” successfully, when I look at Ganache, but for some reason, it just doesn’t get logged in the console:
https://gyazo.com/8c93a9e2406deaaef6c479db4b8fdb30
I’m running Truffle v5.1.54 on Windows 10.
Hey @Ako1, hope you are well.
Now the truffle error shows up when your compiler version is not the same that your contracts.
You can always change it on the truffle-config.js
file, at the end of it you can specify the version of the compiler that you need to use.
If you have any more questions, please let us know so we can help you!
Carlos Z.
I am getting conflicting errors,
I am usung the right truffle version. But the statement "Truffle is currently using solc 0.5.0, makes it confusing for me. Kindly explain the reason of this messages to me.
You just have to delete the first “//” at the begining of the code line, that way you are uncommenting that code line in order to activate that option.
If you have any more questions, please let us know so we can help you!
Carlos Z.
Would appreciate if you helped me with the problem I had in my last post, it’s a few posts above this one.
Also, I now ran into a new problem when following along the “payable functions” video - when I copy filip’s code and try to migrate, I get this error, which I’m having trouble making any sense of: https://gyazo.com/79122e9a82ed3951e0394c566cbf464e
Running Truffle 5.1.54 and Ganache 2.5.4 Could it be some sort of backwards compatibility issue?
Hey,
Use async is much better here, you can avoid that callback hell.
module.exports = async function (deployer) {
await deployer.deploy(Testing)
const instance = await Testing.deployed();
await instance.setMessage('Hello');
const result = await instance.getMessage();
console.log(result)
};
I need to check your code as you are hitting a revert. Post your contract here.
cheers