Quick Start
Here is a quick Start guide for using the DATUM Oracles
Install the Contract library
The best way to interact with oracles is to use one of our official libraries:
# Install via NPM
npm i datum-contracts
Make your first request
To make your first request, import the Oracles interface you want to try out
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.14;
import "datum-contracts/interfaces/PriceOracleInterface.sol";
Here is an full example the contract for testing Price Oracles :
// 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
);
}
}
Go to Remix and Compile the Contract after heading over to the tab
Later connect with
Injected Web3 Provider
with Metmask , deploy the contract From Deploy tab on Sepolia for testingThen you can call
getPrice()
to get the latest price from the Oracle.
Last updated