compiler-errors - 无法编译多个 Solidity 版本
问题描述
我正在尝试(通过 Hardhat)编译一个合同,该合同导入了几个具有不同 Solidity 版本的接口,但我收到以下错误:
Error HH606: The project cannot be compiled, see reasons below.
These files and its dependencies cannot be compiled with your config. This can happen because they have incompatible Solidity pragmas, or don't match any of your configured Solidity compilers.
* contracts/FlashLoaner.sol
Flashloaner.sol:
pragma solidity >=0.5.0 <=0.8.0;
import '@uniswap/v2-periphery/contracts/interfaces/IWETH.sol';
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import '@aave/protocol-v2/contracts/interfaces/ILendingPool.sol'; //---> Issue
import "hardhat/console.sol";
contract FlashLoaner {
struct MyCustomData {
address token;
uint256 repayAmount;
}
address public logicContract;
function execute(address _weth, address _contract) external view {
console.log(_weth);
}
}
问题出在@aave/protocol-v2/contracts/interfaces/ILendingPool.sol
. 如果我把它注释掉,我的合同就很好了。
IlendingPool.sol:pragma solidity 0.6.12;
IERC20.sol:pragma solidity ^0.5.0;
IWETH.sol:pragma solidity >=0.5.0;
安全帽配置:
module.exports = {
solidity: {
compilers: [
{
version: "0.5.7"
},
{
version: "0.8.0"
},
{
version: "0.6.12"
}
]
}
...
解决方案
我有一个类似的问题。
就我而言,我的合同使用了 pragma solidity 版本 ^0.8.0
为了解决这个问题,我将这些行添加到我的 hardhat.config.js 中(大多数情况下在现有的 module.exports 中)。
module.exports = {
solidity: "0.8.0",
}
我只是删除了版本之前的“^”。我希望它可以帮助某人。
推荐阅读
- javascript - “else”无法使用 slideToggle 处理我的 Jquery 代码
- excel - 找不到对象 - 将 excel 范围从一张表复制到另一张表
- postgresql - 如何使用 CSV 文件多次更新 Postgresql
- jboss - JBoss Web Server 和 JBoss EAP 在运行 Redhat Decision Manager 方面有什么区别?
- javascript - 使用 SDK 在特定持续时间后自动终止 EC-2 实例
- c# - 如何在 C# 中的 Android Xamarin 中设置按钮的布局宽度?
- python - 如何将多个用户的输入附加到多个不同的列表
- laravel - URL 路由:Laravel
- xml - VBA Excel:XML,获取特定节点
- forms - 无法从子表单中隐藏我的记录选择器