readOracle

The readOracle method is designed to retrieve the value from a specific oracle. This enables users to access data fetched by an oracle, which serves as a reliable source of information sourced from external APIs or other data providers.

Usage

As an example, we will utilize the CoinGecko public API oracle, which provides the Ethereum price in USD: CoinGecko Ethereum API.

const readOracleRes = await readerOrFactory.readOracle(
  "QmbXhtjAJysMMA69KkB8KohsEDTZA2PXuhYdAQcHjjQFit"
); // Content ID of the Oracle

You can utilize either type of SDK instance, be it the basic IExecOracleFactory or the IExecOracleReader, to invoke the readOracle method.

Return value example

{
  value: 1995.74,
  date: 1700047387
}

Parameters

cid

Content ID of the Oracle to be read.

const readOracleRes = await readerOrFactory.readOracle(
  "QmbXhtjAJysMMA69KkB8KohsEDTZA2PXuhYdAQcHjjQFit"
);

Last updated