I am trying to get the price feed for BUSD/USD using the chainlink pricefeed oracle but it tells me that the code was reverted. this is also happening when i switch to any other token, i am using the kovan test net
this is the error i get
call to PriceConsumerV3.getLatestPrice call to PriceConsumerV3.getLatestPrice errored: VM execution error. Reverted 0x
and this is my code
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
AggregatorV3Interface internal priceFeed;
/**
* Network: Kovan
* Aggregator: ETH/USD
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
*/
constructor() public {
priceFeed = AggregatorV3Interface(0xcBb98864Ef56E9042e7d2efef76141f15731B82f);
}
/**
* Returns the latest price
*/
function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return price;
}
}
CodePudding user response:
You have set incorrect ChainLink address!
correct ETH/USD address: 0x9326BFA02ADD2366b30bacB125260Af641031331
Address you are using in on BSC network, not Kovan network!
CodePudding user response:
If you are trying to get BUSD/USD via a price feed on Kovan testnet, it is not available on that specific network. It is available on Ethereum mainnet however.
If you are testing using the price feed, you can always use a mock contract to mock the behavior of the feeds for testing purposes only.