33

hardhat solidity不同版本,不能正常编译

 4 years ago
source link: https://learnblockchain.cn/question/1933
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
hardhat solidity不同版本,不能正常编译

hardhat solidity不同版本,不能正常编译

hardhat.config.js

compilers: [
      {
        version: "0.7.0"
      },
      {
        version: "0.7.3"
      },
      {
        version: "0.8.0"
      },
      {
        version: "0.8.1"
      },
    ]
  },

编译时异常提示

npx hardhat compile
Solidity 0.8.0, 0.8.1 are not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly.

Learn more at https://hardhat.org/reference/solidity-support"

Error HH606: The project cannot be compiled, see reasons below.

These files import other files that use a different and incompatible version of Solidity:

  • @soliditylabs/erc20-permit/contracts/ERC20Permit.sol (^0.7.0) imports @openzeppelin/contracts/token/ERC20/ERC20.sol (^0.8.0) and @openzeppelin/contracts/utils/Counters.sol (^0.8.0)

These files depend on other files that use a different and incompatible version of Solidity:

  • contracts/ERC20PermitToken.sol (^0.7.0) depends on @openzeppelin/contracts/token/ERC20/ERC20.sol (^0.8.0), @openzeppelin/contracts/utils/Counters.sol (^0.8.0) and 2 other files. Use --verbose to see the full list.

To learn more, run the command again with --verbose

Read about compiler configuration at https://hardhat.org/config

For more info go to https://hardhat.org/HH606 or run Hardhat with --show-stack-traces

Tiny熊 - 布道者 1天前

  擅长:智能合约,以太坊

看提示是你在合约里应用了不兼容的版本,需要修改一下相关合约源代码的版本号。

或者尝试为单个文件设置编译器:

solidity: {
    compilers: [...],
    overrides: {
      "contracts/Foo.sol": {
        version: "0.5.5",
        settings: { }
      }
    }
  }

不过,我自己也没使用过这个方法,可参考文档:https://hardhat.org/guides/compile-contracts.html

您需要登录后才可以回答问题,登录 或者 注册

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK