Skip to content
Verified contractPartialMIT

ChainlinkOracle

Address0x025947084c15e34bb89b8276a54719dfd745008b
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.18

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.18+commit.87f61d96
Language
solidity
Optimization
No
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
17,329,147
Creation transaction
0x84aed92d07…c54a2c22af

ChainlinkOracle.sol

// File: @chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol


pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

// File: chainlink.sol


pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT
contract ChainlinkOracle {
    AggregatorV3Interface internal priceFeed;

    /**
     * Contract constructor.
     * @param aggregatorAddress The address of the Chainlink aggregator contract to fetch the price data.
     */
    constructor(address aggregatorAddress) {
        priceFeed = AggregatorV3Interface(aggregatorAddress);
    }

    /**
     * Returns the latest price from the configured Chainlink aggregator.
     * @return The latest price.
     */
    function getLatestPrice() public view returns (int256) {
        (, int256 price, , , ) = priceFeed.latestRoundData();
        return price;
    }

    /**
     * Returns the latest round data from the configured Chainlink aggregator.
     * @return roundId The round ID.
     * @return price The price for the round.
     * @return startedAt The start timestamp for the round.
     * @return updatedAt The update timestamp for the round.
     * @return answeredInRound The round ID where the answer was computed.
     */
    function getLatestRoundData()
        public
        view
        returns (
            uint80 roundId,
            int256 price,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        )
    {
        return priceFeed.latestRoundData();
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.