← Back to portal

Read a feed

Every Oracle Gateway adapter implements the standard Chainlink IAggregatorV3Interface. If you've integrated Chainlink before, you already know the API.

Solidity

import { IAggregatorV3Interface } from "@rome-protocol/oracle-gateway";

contract MyConsumer {
    IAggregatorV3Interface public priceFeed;

    constructor(address feed) {
        priceFeed = IAggregatorV3Interface(feed);
    }

    function currentPrice() external view returns (int256) {
        (, int256 price, , , ) = priceFeed.latestRoundData();
        return price; // 8 decimals
    }
}

viem

import { createPublicClient, http, parseAbi } from "viem";
import { defineChain } from "viem";

// Define the Rome chain you're consuming feeds from. Replace the
// placeholders with values from rome-protocol/registry's chain.json.
const romeChain = defineChain({
  id: <chain-id>,
  name: "Rome <chain>",
  nativeCurrency: { name: "USDC", symbol: "USDC", decimals: 18 },
  rpcUrls: { default: { http: ["https://<chain>.<env>.romeprotocol.xyz"] } },
});

const client = createPublicClient({ chain: romeChain, transport: http() });

const price = await client.readContract({
  address: "0x...adapter-address...",
  abi: parseAbi(["function latestRoundData() view returns (uint80,int256,uint256,uint256,uint80)"]),
  functionName: "latestRoundData",
});

Staleness

Every adapter reverts with StalePriceFeedif the Solana source hasn't published within the staleness window (1s–24h, configurable at deploy time). Consumers should handle this as a “feed unavailable” case.

Historical rounds

getRoundData(roundId) reverts with HistoricalRoundsNotSupported. Solana oracles are not slot-indexed; only the latest round is available. For historical analysis, index events off-chain.