solidity - 指定的输入源无效
问题描述
使用 remix IDE 构建智能合约时,通过以下导入获取 Invalid input source specified 错误
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
与您自己的合同在同一文件夹中命名的合同,因此此导入失败。
最好的解决方案是将 PR 提交到aave/flashloan-box存储库,使所有导入路径都是绝对的。
推荐阅读
- react-admin - 如何使用演示左侧显示的可折叠菜单?
- spring-boot - 如何修复“在根项目'genie-voucher-module'中找不到任务'build'”
- php - 使用 PhpSpreadsheet 从字符串创建 CSV 文件
- c# - 多线程和随机的奇怪行为
- excel - 为什么不能在 MS Excel 中重命名附件?
- android - 切换到插件 android gradle 3.3 时构建项目 io.realm.DefaultRealmModule 时出错
- angular - 用户单击按钮后,将数组以角度传递到下一页
- android - 我该如何解决这个错误?(我有 3 个 xml 文件和 1 个 java 类文件)
- python - 没有切片和导入的滚动/滑动窗口迭代器?
- c# - 在 C# 中,对于长音频,Speaker Diarization 始终返回零