updateOracle

The updateOracle method serves to refresh an existing oracle with the latest data fetched from the linked API. This ensures that the oracle maintains up-to-date information, enhancing its reliability and usefulness for downstream applications.

Usage

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

const updateOracleRes = factory.updateOracle({
  cid: "QmbXhtjAJysMMA69KkB8KohsEDTZA2PXuhYdAQcHjjQFit", // Content ID of the Oracle
  targetBlockchains: ["134", "137"], // Target blockchain IDs, 137 for polygon, 134 for iExec (required)
}).subscribe({
    next: (data) => {
      console.log("next", data);
    },
    error: (error) => {
      console.log("error", error);
    },
    complete: () => {
      console.log("Oracle update Completed");
    }, 
  });

Return value example

These are the possible events iExec may send to the subscriber:

Parameters

cid

Content ID of the Oracle that needs to be updated.

const updateOracleRes = factory.updateOracle({
    cid: "QmbXhtjAJysMMA69KkB8KohsEDTZA2PXuhYdAQcHjjQFit",
    // Other parameters...
}).subscribe({
    next: (data) => {
      console.log("next", data);
    },
    error: (error) => {
      console.log("error", error);
    },
    complete: () => {
      console.log("Oracle update Completed");
    }, 
  });

targetBlockchains (optional)

Array of target blockchain IDs where the oracle is deployed. 137 for polygon, 134 for iExec.

const updateOracleRes = factory.updateOracle({
    targetBlockchains: ["134", "137"],
    // Other parameters...
}).subscribe({
    next: (data) => {
      console.log("next", data);
    },
    error: (error) => {
      console.log("error", error);
    },
    complete: () => {
      console.log("Oracle update Completed");
    }, 
  });

Last updated