[英]Solidity, Solc Error: Struct containing a (nested) mapping cannot be constructed
[英]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”
这是错误的照片 - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7
我所有的合同都使用 ^0.8.0 编译指示。 我的 truffle-config 也使用与您在此处看到的相同的版本 - https://gyazo.com/1ec8b28ca48902c091004f8659cf678d
请帮忙。 非常感谢。
省略“^”。 不是version:"^0.8.0"
compilers: {
solc: {
version: "0.8.0"
}
}
如果您使用 windows 将您的“truffle.js”文件名更改为“truffle.config.js”并在您的 truffle 配置文件中添加这行代码(如果它不存在)
compilers: {
solc: {
version: "0.8.0"
确保不要在
version:"0.8.0"
}
}
@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"
}
从 truffle-config.js 中取消注释这一行
compilers: {
solc: {
version: "0.8.10", // <-- this one
.
.
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.