Created
October 17, 2021 09:50
-
-
Save dome/ed43639334a72249eeef23b773b7ac39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| pragma solidity ^0.6.6; | |
| import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; | |
| contract ChainlinkOracle { | |
| AggregatorV3Interface internal priceFeed; | |
| /** | |
| * Network: Kovan | |
| * Aggregator: ETH/USD | |
| * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331 | |
| */ | |
| constructor(address _priceFeed) public { | |
| priceFeed = AggregatorV3Interface(_priceFeed); | |
| } | |
| /** | |
| * Returns the latest price | |
| */ | |
| function getLatestPrice() public view returns (int) { | |
| ( | |
| uint80 roundID, | |
| int price, | |
| uint startedAt, | |
| uint timeStamp, | |
| uint80 answeredInRound | |
| ) = priceFeed.latestRoundData(); | |
| return price; | |
| } | |
| function getReferenceData(string memory _bases , string memory _quotes) public view returns ( | |
| int rate, | |
| uint lastUpdatedBase, | |
| uint lastUpdatedQuote | |
| ) { | |
| ( | |
| uint80 roundID, | |
| int price, | |
| uint startedAt, | |
| uint updatedAt, | |
| uint80 answeredInRound | |
| ) = priceFeed.latestRoundData(); | |
| return (price, updatedAt, updatedAt); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment