Chainlink

Introduction

Chainlink enables smart contracts on Opera to leverage extensive off-chain resources, such as tamper-proof price data, verifiable randomness, external APIs, and much more. This documentation describes access to various cryptocurrency price data available to be integrated into decentralized applications running on Opera.

Note, off-chain equity and ETF assets are only traded during standard market hours (9:30 AM – 4:00 PM ET Monday–Friday). Using these feeds outside of those windows is not recommended.

Supported Token Pairs

Currently, the list of supported symbols can be found below. Going forward, this list will continue to expand based on developer needs and community feedback.

Opera Mainnet

Opera Testnet

Querying Prices

Currently, there are two methods for developers to query prices from the Chainlink data feed: Through the Solidity PriceConsumer smart contract running on the hosting blockchain and through an external interface utilizing Chainlink AggregatorInterface ABI.

Solidity

To consume price data, your smart contract should reference AggregatorV3Interface, which defines the external functions implemented by Price Feeds. The latest RoundData function returns five values representing information about the latest price data. See Price Feeds API Reference for more details.

pragma solidity ^0.6.7;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

contract PriceConsumerV3 {

    AggregatorV3Interface internal priceFeed;

    /**
     * Network: Kovan
     * Aggregator: ETH/USD
     * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
     */
    constructor() public {
        priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
    }

    /**
     * Returns the latest price
     */
    function getThePrice() public view returns (int) {
        (
            uint80 roundID, 
            int price,
            uint startedAt,
            uint timeStamp,
            uint80 answeredInRound
        ) = priceFeed.latestRoundData();
        return price;
    }
}

© 2024 Fantom Foundation