Price Data Feeds
Get price info on chain with Chainlink Price Feeds for multiple coin pairs
Types of data feeds
Using Data Feeds
Full Example Contract Code
Last updated
Get price info on chain with Chainlink Price Feeds for multiple coin pairs
Last updated
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.14;
import "datum-contracts/interfaces/PriceOracleInterface.sol"; // For Sepolia
oracleAddress = 0x9eDf5612D5108dD5BcCb2da086a2C52ef58b03a0
PriceOracleV1 _priceOracle =
PriceOracleV1(oracleAddress);_priceOracle.requestPairPrice(
pairAddress
);price = _priceOracle.getLatestPrice(
pairAddress
);// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.14;
// *************************************
// * Minimum Viable Price Oracle *
// *************************************
// This contract shows how to get up and running as quickly as posible with Chainlink's Price Feeds
// We make a simple price request to the Oracle and getLatestPrice
import "datum-contracts/interfaces/PriceOracleInterface.sol";
contract PriceOracleTest {
PriceOracleV1 _priceOracle =
PriceOracleV1(0x9eDf5612D5108dD5BcCb2da086a2C52ef58b03a0);
// Submit a data request to the oracle
/**
Price Feedsfor goerli Address
Pair: BTC/ETH
PairAddress: 0x779877A7B0D9E8603169DdbD7836e478b4624789
*/
function requestPrice() public {
_priceOracle.requestPairPrice(
0x779877A7B0D9E8603169DdbD7836e478b4624789
);
}
// Fetch the resolved price from the Optimistic Oracle that was settled.
function getPrice() public view returns (uint) {
return
_priceOracle.getLatestPrice(
0x779877A7B0D9E8603169DdbD7836e478b4624789
);
}
}