Chainlink
Install Dependencies
forge install smartcontractkit/chainlink
Using in contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "lib/chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract SampleOracle {
///@dev Asset Pricefeed interface from Chainlink
AggregatorV3Interface public immutable priceFeed;
constructor (address priceFeedAddress) {
priceFeed = AggregatorV3Interface(priceFeedAddress);
}
function getPrice() {
(,int price,,,) = priceFeed.latestRoundData();
}
}
Last updated