指定的输入源无效

Invalid input source specified

在使用 remix IDE

构建智能合约时,以下导入出现指定输入源无效错误
import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/FlashLoanReceiverBase.sol"; 

在 remix 中组合一个超级基本的示例智能合约。如果我不包含 import 语句,它编译得很好。

pragma solidity ^0.6.6;
import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/FlashLoanReceiverBase.sol";
contract Inbox {
    string public message; 
    
    constructor(string memory initialMessage) public {
        message = initialMessage;
    }
    
    function setMessage(string memory newMessage) public {
        message = newMessage;
    }
    
    function getMessage() public view returns (string memory) {
        return message;
    }
}

出现此问题是因为使用相对路径进行嵌套导入。

FlashLoanReceiverBase.sol 正在尝试导入相对路径 ./IFlashLoanReceiver.sol(不是绝对路径 https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/IFlashLoanReceiver.sol)。

由于您在自己的合同所在的文件夹中没有名为 IFlashLoanReceiver.sol 的合同,因此导入失败。

最佳解决方案是向 aave/flashloan-box 存储库提交 PR,使所有导入路径成为绝对路径。