编译 AggregatorV2V3Interface 会导致 TypeError:接口无法继承。界面
SOlidity 课程:Brownie Fund Me 第 6 课:https://github.com/PatrickAlphaC/brownie_fund_me
编译 AggregatorV2V3Interface导致类型错误:接口无法继承。界面 我在 Contract->test 下添加了一个文件 MockV3Aggregator.sol 来部署模拟。但是,当我使用“browniecompile”时,出现以下错误:
PS C:\Users\user\Documents\BC\demos\brownie_fund_me> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.18.1 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.6.0
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-----------------^
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:59:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-------------------^
SOlidity course: Brownie Fund Me Lesson 6: https://github.com/PatrickAlphaC/brownie_fund_me
Compiling AggregatorV2V3Interface leads to TypeError: Interfaces cannot inherit. interface
I have added a file MockV3Aggregator.sol under contract->test to deploy a mock. However, when I use "brownie compile" I get the following errors:
PS C:\Users\user\Documents\BC\demos\brownie_fund_me> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.18.1 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.6.0
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-----------------^
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:59:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-------------------^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能会在 Brownie 、 Hardhat 或任何其他开发框架中遇到此错误。当您的代码尝试访问 chainlink 合约时,就会发生这种情况。
Ex - import "@chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
MockV3Aggregator 也需要访问其他接口。
解决方案
如果我使用 0.6.6,它对我来说效果很好。
You might get this error in brownie , hardhat or any other dev framework. This will occur when your code is trying to access chainlink contracts.
Ex - import "@chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
MockV3Aggregator need to access other interfaces too.
Solution
It works well for me if I Use 0.6.6.
通过右键单击使用 Solidity 插件更改 VSCode 中的编译器版本
“Solidity:将工作区编译器版本(远程)”更改为 0.6.0 或以上任何内容都没有帮助。
Brownie 将忽略这一点并尝试获取您的 pragma Solidity 起点范围内的最高版本。
编译指示可靠性≥0.6.0 <0.9.0;
这里的起点是 0.6.0,因此 Brownie 将使用 0.6.12 并尝试编译此文件,而不管 VSCode 的设置如何。
解决方案:
非常简单,将起点更改为更高的值,Brownie 将使用正确的 solc。
没那么简单...
这可能会破坏你的代码。因此可能需要进行一些编辑。
Changing the compiler version in VSCode with the solidity plugin via right click
"Solidity: change workspace compiler version (Remote)" to 0.6.0 or anything above won't help.
Brownie will ignore this and try to get the highest version in the range of your pragma solidity starting point.
pragma solidity >=0.6.0 <0.9.0;
The starting point here is 0.6.0 so Brownie will use 0.6.12 and try to compile this file regardless of the settings of VSCode.
Solution:
Very simple, change the starting point into something higher and Brownie will use the correct solc.
Not so simple ...
This might break your code. So some editing might be in order.
我按照相同的教程遇到了同样的问题。在 Brownie-config.yml 文件中,您只需添加:
version = 0.6.6
在 solc 部分下(位于编译器部分下)。
这意味着这是编译器版本的问题,显然不能像我想象的那样通过 Visual Studio Code 轻松修改
I had the same issue following the same tutorial. In the brownie-config.yml file you just need to add:
version = 0.6.6
Under the solc section (which is under the compiler section).
This means that it's a problem with the compiler version, which apparently cannot be easily modified via Visual Studio Code as I thought
将 pragma Solidity 更改为 0.8.0 立即编译了合约。
changing pragma solidity to 0.8.0 instantly compiled the contract.