Reading official Truffle docs, I noticed Truffle not support Solidity 6.0
pragma solidity >=0.4.21 <0.6.0;
Are there any ways to use Truffle with Solidity 6.0?
Yes this works with this migration
pragma solidity >=0.4.21 <0.7.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;
}
}
And this compiler settings
compilers: {
solc: {
version: "^0.6.0",
And also need re-install Truffle to latest version
You can set the solidity version in the truffle config file.
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
},
compilers: {
solc: {
version: "0.6.0",
settings: {
optimizer: {
enabled: true, // Default: false
runs: 1000, // Default: 200
},
},
},
},
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.