【问题标题】:How to compile older zeppelin-solidity contract implementations如何编译旧的 zeppelin-solidity 合约实现
【发布时间】:2020-04-29 19:50:20
【问题描述】:

我使用 npm 安装了 zeppelin-solidity 包,以使用 erc-721 合约。

但问题是当我使用松露编译时,它给出了以下错误:

/Users/me/dev/myfolder/erc721/node_modules/zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.24;
^----------------------^

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.4.24".
Please update your truffle config or pragma statement(s).
(See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)

编译失败。见上文。

我看到的一些答案建议将 pragma solidity 提高到 0.5,但是如何更改包含文件中的版本?

此外,如果这个合同是旧的,我应该使用它,还是有更好的 erc721 实现可用?

更新: 我已尝试如下更改 solc 编译器,但错误仍然存​​在:

compilers: {
    solc: {
        version: "^0.4.24",
        //parser: "solcjs",
        optimizer: {
            enabled: true,
            runs: 200
        }
    }
  }

【问题讨论】:

    标签: solidity truffle openzeppelin


    【解决方案1】:

    写一个名为truffle.js的文件如:

      module.exports = {
      // Configure your compilers
      compilers: {
        solc: {
          version: ">=0.4.24", // Fetch exact version from solc-bin (default: truffle's version)
        }
      },
    };
    

    并将其放在项目根目录下。就是这样。

    阅读有关 Truffle 配置的更多信息:https://www.trufflesuite.com/docs/truffle/reference/configuration

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 2019-12-19
      • 2017-08-19
      • 1970-01-01
      • 2022-12-03
      • 2019-06-22
      • 2019-06-16
      相关资源
      最近更新 更多