[英]Chainlink Returned error: VM Exception while processing transaction: revert
I am testing this code on Remix:我正在 Remix 上测试这段代码:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
AggregatorV3Interface internal priceFeed;
/**
* Network: Kovan
* Aggregator: ETH/USD
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
*/
constructor() {
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
}
/**
* Returns the latest price
*/
function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return price;
}
}
Compilation and deployment seem to be executed correctly, however I receive this error:编译和部署似乎正确执行,但是我收到此错误:
call to PriceConsumerV3.getLatestPrice errored: Returned error: VM Exception while processing transaction: revert
调用 PriceConsumerV3.getLatestPrice 出错:返回错误:处理事务时出现 VM 异常:还原
Any suggestion?有什么建议吗?
I've seen this error when deploying to the Javascript VM我在部署到Javascript VM时看到了这个错误
It's due to the contract you are trying to call not being available on the VM you are using.这是因为您尝试调用的合同在您使用的 VM 上不可用。 You'll need to switch to the Injected Web3 option.
您需要切换到Injected Web3选项。
The deployment will also require having a wallet set up as you interact with an actual blockchain.部署还需要在您与实际区块链交互时设置钱包。 The example you reference is using the Kovan Tes.net.
您引用的示例使用的是 Kovan Tes.net。
Here are a few other links for reference这里有几个其他链接供参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.