Created
August 13, 2023 06:24
-
-
Save jokereven/21e8227e8b6e178f6dfbef4fefc2aab9 to your computer and use it in GitHub Desktop.
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.7; | |
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | |
/** | |
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED | |
* VALUES FOR CLARITY. | |
* THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. | |
* DO NOT USE THIS CODE IN PRODUCTION. | |
*/ | |
/** | |
* If you are reading data feeds on L2 networks, you must | |
* check the latest answer from the L2 Sequencer Uptime | |
* Feed to ensure that the data is accurate in the event | |
* of an L2 sequencer outage. See the | |
* https://docs.chain.link/data-feeds/l2-sequencer-feeds | |
* page for details. | |
*/ | |
contract DataConsumerV3 { | |
AggregatorV3Interface internal dataFeed; | |
/** | |
* Network: Sepolia | |
* Aggregator: BTC/USD | |
* Address: 0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43 | |
*/ | |
constructor() { | |
dataFeed = AggregatorV3Interface( | |
0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43 | |
); | |
} | |
/** | |
* Returns the latest answer. | |
*/ | |
function getLatestData() public view returns (int) { | |
// prettier-ignore | |
( | |
/* uint80 roundID */, | |
int answer, | |
/*uint startedAt*/, | |
/*uint timeStamp*/, | |
/*uint80 answeredInRound*/ | |
) = dataFeed.latestRoundData(); | |
return answer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment