【问题标题】:Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported未找到源“@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol”:不支持文件导入回调
【发布时间】:2022-11-27 11:05:30
【问题描述】:

我在同一个问题上看到了很多问题并尝试了所有问题,但它仍然没有解决我的回调问题。

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";

contract FundMe {
    using SafeMathChainlink for uint256;

error message doesn't go away for me

这是我的 brownie-config.yaml 文件

dependencies:
  # -<organization/repo>@<version>
  - smartcontractkit/chainlink-brownie-contracts@1.1.1
compiler:
  solc:
    remappings:
      - "@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1"

之后我编译并成功,但错误不会消失。 brownie-compile

对此的任何帮助都是 EPIC。 先感谢您

【问题讨论】:

  • 你可以忽略它。这是棉绒问题
  • 即使它是一个显示直接错误?好的,谢谢
  • 编译时不会抛出错误,对吧?
  • 它没有,但编译后仍然显示错误

标签: solidity brownie


【解决方案1】:

我有同样的问题。这就是解决我系统上的问题的原因:

  • 我通过终端中的“nmp -g list”检查了我安装的 solicity 版本。看来我安装了 0.8.xx 版本。
  • 我通过“npm install -g solc@0.6.6”降级到版本 0.6.6
  • 我重新检查了安装的版本,它给了我这个: enter image description here
  • 我通过“brownie compile”进行了编译并且它起作用了,尽管仍然有“红线”说明文件中的问题。生成了json文件

希望这会有所帮助,已经搜索了一段时间。

【讨论】:

    【解决方案2】:

    编译器不知道文件在哪里,所以只需创建一个新文件夹在名为 tests 的合同文件夹中然后创建一个新的文件命名:AggregatorV3Interface.sol然后将此代码粘贴到其中:

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    
    interface AggregatorV3Interface {
      function decimals() external view returns (uint8);
    
      function description() external view returns (string memory);
    
      function version() external view returns (uint256);
    
      // getRoundData and latestRoundData should both raise "No data present"
      // if they do not have data to report, instead of returning unset values
      // which could be misinterpreted as actual reported values.
      function getRoundData(uint80 _roundId)
        external
        view
        returns (
          uint80 roundId,
          int256 answer,
          uint256 startedAt,
          uint256 updatedAt,
          uint80 answeredInRound
        );
    
      function latestRoundData()
        external
        view
        returns (
          uint80 roundId,
          int256 answer,
          uint256 startedAt,
          uint256 updatedAt,
          uint80 answeredInRound
        );
    }
    

    在这之后重新编译项目然后运行,它将运行而不会出现任何错误,您将得到结果。 欲了解更多信息,请访问 :: this question

    【讨论】:

      【解决方案3】:

      我确实通过询问我正在使用的 IDE (Visual Studio Code) 使用接口 v0.7 的版本来解决这个问题,因为我想导入 v0.7 接口:

      @chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol
      

      仅供参考:我正在关注一个 YouTube 教程,该教程告诉您将 @chainlink 重新映射到版本 1.1.1 的 git 路径,但界面文件现在已压缩,因此我选择 v0.7,其中文件仍然可用。

      【讨论】:

        【解决方案4】:

        我遇到了同样的问题只是尝试将 solidity 版本更改为 0.8.7 并将 chainlink 版本更改为 0.8

        pragma solidity ^0.8.7;
        
        import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
        

        【讨论】:

          猜你喜欢
          • 2023-01-07
          • 2021-07-06
          • 2022-11-11
          • 2021-12-17
          • 2021-07-23
          • 2021-05-04
          • 1970-01-01
          • 2021-08-25
          • 2021-03-12
          相关资源
          最近更新 更多