Last active
March 23, 2022 22:18
-
-
Save alexroan/c7b9cd9afd58e69e951446273d252be5 to your computer and use it in GitHub Desktop.
Chainlink-PriceConsumer.sol
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.7; | |
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorInterface.sol"; | |
contract PriceConsumer { | |
AggregatorInterface internal priceFeed; | |
/** | |
* Network: Kovan | |
* Aggregator: ETH/USD | |
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331 | |
*/ | |
constructor() public { | |
priceFeed = AggregatorInterface(0x9326BFA02ADD2366b30bacB125260Af641031331); | |
} | |
/** | |
* Returns the latest price | |
*/ | |
function getLatestPrice() public view returns (int256) { | |
return priceFeed.latestAnswer(); | |
} | |
/** | |
* Returns the timestamp of the latest price update | |
*/ | |
function getLatestPriceTimestamp() public view returns (uint256) { | |
return priceFeed.latestTimestamp(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment