简体   繁体   English

错误:Truffle 当前使用的是 solc 0.5.16,但您的一个或多个合约指定“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”

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.

相关问题 Solidity,Solc 错误:无法构造包含(嵌套)映射的结构 - Solidity, Solc Error: Struct containing a (nested) mapping cannot be constructed 无法使用正确的 Solc 版本编译 Solidity 文件 - Cant compile solidity files using correct Solc version 如何使用 truffle 框架将大量值转换为solidity? - How to convert the value in big number in solidity using truffle framework? Solidity 0.8.0 中的 ParserError - ParserError in Solidity 0.8.0 Solidity 和 truffle 的编译器问题 - compiler problem with solidity and truffle 无法解决 Solidity 错误 - ParserError: Expected &#39;;&#39; 但得到了“数字”-&gt; first.sol:2:17: | 2 | Pragma 坚固性 0.8.7; | ^^^ - Unable to solve solidity error- ParserError: Expected ';' but got 'Number' --> first.sol:2:17: | 2 | Pragma solidity 0.8.7; | ^^^ 使用 Truffle 部署合约的 53 位问题 - Problems about 53 bits deploying contracts with Truffle 使用带有@usedapp 和@ethersproject/contracts 的智能合约的奇怪错误 - Weird error using Smart Contracts with @usedapp and @ethersproject/contracts 多边形:“pragma solidity ^0.8.7”与链链接的 Solidity 构建失败 - Polygon: Solidity build failed for 'pragma solidity ^0.8.7' with chainlink Truffle deploy 编译合约但不迁移到网络 - Truffle deploy compiles contracts but doesnt migrate to network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM