Last active
March 11, 2022 13:39
-
-
Save alexroan/0c5928a00094810d2ba01fd8d1083581 to your computer and use it in GitHub Desktop.
PriceConsumerV3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example code is designed to quickly deploy an example contract using Remix. | |
pragma solidity ^0.6.7; | |
import "https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; | |
contract PriceConsumerV3 { | |
AggregatorV3Interface internal priceFeed; | |
/** | |
* Network: Kovan | |
* Aggregator: ETH/USD | |
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331 | |
*/ | |
constructor() public { | |
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AggregatorV3Interface.sol changed locations. It is now here: https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol
Please update the URL or borrow from my fork: https://gist.github.com/dwightjl/f2b0dc524940b456b7c6a20113c74d29
Also update to
pragma solidity ^0.8.0;