Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active March 16, 2021 13:24
Show Gist options
  • Save alexroan/3910b5fbd39cdb5177521e88c907798d to your computer and use it in GitHub Desktop.
Save alexroan/3910b5fbd39cdb5177521e88c907798d to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.7+commit.b8d736ae.js&optimize=false&gist=
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.7;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol";
contract PriceConsumer {
AggregatorInterface internal priceFeed;
/**
* Network: Ropsten
* Aggregator: ETH/USD
* Address: 0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507
*/
constructor() public {
priceFeed = AggregatorInterface(0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507);
}
/**
* 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