OpenZeppelin ERC-721 实现使用不同的 Solidity 版本进行安全数学

问题描述

我正在尝试使用 OpenZeppelin 的 ERC-721 from the example on their website,使用松露。

在我的松露中,我已将 solc 编译器版本更改为 0.6.0。

compilers: {
    solc: {
      version: "^0.6.0",// Fetch exact version from solc-bin (default: truffle's version)
 }
    }
  }

当我尝试“松露”编译时,出现以下错误

CompileError: @openzeppelin/contracts/math/SafeMath.sol:1:1: ParserError: 源文件需要不同的编译器版本(当前编译器是 0.6.12+commit.27d51765.Emscripten.clang) - 请注意每晚构建被认为严格低于发布的版本 编译指示可靠性 ^0.5.0; ^--------------------^,@openzeppelin/contracts/token/ERC20/ERC20.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - 请注意,每晚构建被认为是严格小于发布版本 pragma solidity ^0.5.0; ^--------------------^,@openzeppelin/contracts/token/ERC721/ERC721.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - 请注意,夜间构建被认为是严格小于发布版本 编译指示可靠性 ^0.5.0; ^--------------------^

错误:Truffle 当前正在使用 solc ^0.6.0,但是您的一个或多个 合约指定“pragma solidity ^0.5.0”。请更新您的松露 config 或 pragma 语句。 (看 https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration 有关配置 Truffle 以使用特定 solc 编译器的信息 版本。)

我不明白的是,如果底层的 safemath 实现需要较旧的 solc 编译器,而 ERC-721 需要较新的 solc 编译器,那么任何人都可以编译它们吗?为什么 solc 0.6.0 不能编译旧的 0.5.0 solidity 代码

谁能解释一下如何解决这种循环依赖?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...