// SPDX-License-Identifier: MIT
import "witnet-solidity-bridge/contracts/interfaces/IWitnetPriceRouter.sol";
import "witnet-solidity-bridge/contracts/interfaces/IWitnetPriceFeed.sol";
contract MyContractCelo {
IWitnetPriceRouter public immutable witnetPriceRouter;
IWitnetPriceFeed public celoEurPrice;
* IMPORTANT: replace the address below with the WitnetPriceRouter address
* of the network you are using! Please find the address here:
* https://docs.witnet.io/smart-contracts/price-feeds/contract-addresses
witnetPriceRouter = IWitnetPriceRouter(0x6f8A7E2bBc1eDb8782145cD1089251f6e2C738AE);
updateCeloEurPriceFeed();
/// Detects if the WitnetPriceRouter is now pointing to a different IWitnetPriceFeed implementation:
function updateCeloEurPriceFeed() public {
IERC165 _newPriceFeed = witnetPriceRouter.getPriceFeed(bytes4(0x21a79821));
if (address(_newPriceFeed) != address(0)) {
celoEurPrice = IWitnetPriceFeed(address(_newPriceFeed));
/// Returns the CELO / EUR price (6 decimals), ultimately provided by the Witnet oracle, and
/// the timestamps at which the price was reported back from the Witnet oracle's sidechain
function getCeloEurPrice() external view returns (int256 _lastPrice, uint256 _lastTimestamp) {
(_lastPrice, _lastTimestamp,,) = celoEurPrice.lastValue();