【问题标题】: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”
【发布时间】:2021-09-05 06:18:18
【问题描述】:
【问题讨论】:
标签:
blockchain
solidity
truffle
erc20
openzeppelin
【解决方案1】:
省略“^”。不是version:"^0.8.0"。
compilers: {
solc: {
version: "0.8.0"
}
}
【解决方案2】:
@Yilmaz 是正确的,需要修改版本。将 truffle-config.js 文件更改为正确的编译器版本。确保您有一个版本集。我有同样的错误,因为没有设置版本。如果您的文件如下所示:
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"
// }
}
把它改成这样:
compilers: {
solc: {
version: "^0.8.0"
}
【解决方案3】:
从 truffle-config.js 中取消注释这一行:
compilers: {
solc: {
version: "0.8.10", // <-- this one
.
.
...