我正在尝试通过Hardhat编译一个智能合约,该合约导入了几个使用不同Solidity版本的接口,但是我遇到了以下错误:
问题出在
IlendingPool.sol:
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;
Hardhat.config:module.exports = {
solidity: {
compilers: [
{
version: "0.5.7"
},
{
version: "0.8.0"
},
{
version: "0.6.12"
}
]
}
...