执行以坚固性和混音恢复
我已经通过使用链链接界面写了一个简单的代码,以获取ETH价格:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract ABI {
AggregatorV3Interface internal priceFeed;
constructor() public {
priceFeed = AggregatorV3Interface(0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c);
}
function latestPrice() public view returns (int256) {
(, int256 answer,,,) = priceFeed.latestRoundData();
return answer;
}
}
问题是什么时候由混音编译,没有问题,但是执行后,它会引发下面的错误:
致电ContractName
。functionName
errored:rececution descution
您认为问题是什么吗?
I've wrote a simple code for fetching ETH price by using Chainlink interfaces as below:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract ABI {
AggregatorV3Interface internal priceFeed;
constructor() public {
priceFeed = AggregatorV3Interface(0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c);
}
function latestPrice() public view returns (int256) {
(, int256 answer,,,) = priceFeed.latestRoundData();
return answer;
}
}
The problem is when is being compiled by Remix, it has no problem but after execution it throws the error below:
call to ContractName
.FunctionName
errored: execution reverted
Do you think what the problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为您的问题未指定您正在运行脚本的网络,所以我假设您正在使用混音VM仿真器。
指定的链条 Contract 仅在Ethereerum Mainnet上都可以使用。任何其他网络(包括模拟器)都没有在此地址上部署此合同。
要使用Remix中的数据提要合同,您可以创建主网的本地叉,然后连接到IDE中的本地网络。
Because your question didn't specify on which network you're running the script, I'm assuming that you're using the Remix VM emulator.
The specified Chainlink contract is available on Ethereum mainnet only. Any other network (including the emulator) does not have this contract deployed on this address.
To use the data feed contract in Remix, you can create a local fork of the mainnet, and then connect to the local network in the IDE.
将
环境
更改为在Remix IDE中注入Web3
,然后连接到metAmask
。例如,如果您使用的是kovan
网络使用文档。Change
ENVIRONMENT
toInjected Web3
in Remix IDE and connect tometamask
. For example, if you are usingKovan
network use address as mentioned in the docs.