[英]Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity ^0.8.0”
Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity ^0.8.0”错误:Truffle 当前使用的是 solc 0.5.16,但您的一个或多个合约指定“pragma solidity ^0.8.0”
Here is a photo of the error - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7这是错误的照片 - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7
All my contracts are using the ^0.8.0 pragma.我所有的合同都使用 ^0.8.0 编译指示。 My truffle-config is also using the same version as you can see here - https://gyazo.com/1ec8b28ca48902c091004f8659cf678d我的 truffle-config 也使用与您在此处看到的相同的版本 - https://gyazo.com/1ec8b28ca48902c091004f8659cf678d
Please help.请帮忙。 Thank you very much.非常感谢。
Omit the "^".省略“^”。 Not version:"^0.8.0"
不是version:"^0.8.0"
compilers: {
solc: {
version: "0.8.0"
}
} }
If you're using windows change your "truffle.js" file name to "truffle.config.js" and inside your truffle config file add this line of code if it doesn't exist如果您使用 windows 将您的“truffle.js”文件名更改为“truffle.config.js”并在您的 truffle 配置文件中添加这行代码(如果它不存在)
compilers: {
solc: {
version: "0.8.0"
make sure don't use "^" in
version:"0.8.0"
确保不要在version:"0.8.0"
}
}
@Yilmaz is correct that the version needs to be modified. @Yilmaz 是正确的,需要修改版本。 Change the truffle-config.js file to the correct compiler version.将 truffle-config.js 文件更改为正确的编译器版本。 Make sure that you have a version set.确保您有一个版本集。 I had the same error because the version was not set.我有同样的错误,因为没有设置版本。 If your file looks like this:如果您的文件如下所示:
compilers: {
solc: {
// version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: "Byzantium"
// }
}
Change it to something like this:把它改成这样:
compilers: {
solc: {
version: "^0.8.0"
}
Uncomment this line from truffle-config.js从 truffle-config.js 中取消注释这一行
compilers: {
solc: {
version: "0.8.10", // <-- this one
.
.
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.