ETH Price: $2,386.52 (-3.99%)

Contract

0xB2F5659Ee1868D014E38dB33ddB1143Be62B23Dd
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Set X Oracle201586982024-06-24 2:55:23101 days ago1719197723IN
0xB2F5659E...Be62B23Dd
0 ETH0.000068122.49854199
0x60806040201586602024-06-24 2:47:47101 days ago1719197267IN
 Contract Creation
0 ETH0.001636462.73421889

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x1296d3a1...7915d8001
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
PriceFeedStore

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 3 : PriceFeedStore.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";

contract PriceFeedStore is Ownable {
    address public xOracle;
    string public name;
    uint256 public tokenIndex;
    uint256 public decimals;

    // price store
    struct PriceData {
        uint256 price;
        uint256 latestPrice;
        uint256 timestamp;
    }
    mapping(uint256 => PriceData) public pricesData;
    uint256 public latestRound;
    uint256 public latestTimestamp;

    event UpdatePrice(uint256 indexed tokenIndex, uint256 roundId, uint256 price, uint256 latestPrice, uint256 timestamp);
    event SetXOracle(address xOracle);

    modifier onlyXOracle() {
        require(xOracle == msg.sender, "xOracle: forbidden");
        _;
    }

    constructor(address _xOracle, string memory _name, uint256 _tokenIndex, uint256 _decimals) {
        require(_xOracle != address(0), "address invalid");
        xOracle = _xOracle;
        name = _name;
        tokenIndex = _tokenIndex;
        decimals = _decimals;
    }

    // ------------------------------
    // xOracle setPrice
    // ------------------------------
    function setPrice(uint256 _price, uint256 _timestamp) external onlyXOracle { 
        // Sometimes the fulfill request is not in order in a short time.
        // So it's possible that the price is not the latest price.
        // _price is the fulfilling price, but latestPrice is the newest price at the time.
        uint256 latestPrice;
        if (_timestamp > latestTimestamp) {
            latestPrice = _price;
            latestTimestamp = _timestamp;
        } else {
            latestPrice = pricesData[latestRound].latestPrice;
        }

        // next round
        latestRound++;

        // already checked correct tokenIndex in xOracle.setPriceFeedStore
        pricesData[latestRound] = PriceData({
            price: _price,
            latestPrice: latestPrice,
            timestamp: block.timestamp
        });

        emit UpdatePrice(tokenIndex, latestRound, _price, latestPrice, block.timestamp);
    }

    // ------------------------------
    // onlyOwner
    // ------------------------------
    function setXOracle(address _xOracle) external onlyOwner {
        require(_xOracle != address(0), "address invalid");
        xOracle = _xOracle;
        emit SetXOracle(_xOracle);
    }

    // ------------------------------
    // view function
    // ------------------------------
    function getLastPrice() external view returns (uint256, uint256, uint256, uint256) {
        PriceData memory priceData = pricesData[latestRound];
        return (
            latestRound, 
            priceData.price, 
            priceData.latestPrice, 
            priceData.timestamp
        );
    }

    function getPrice(uint256 _roundId) external view returns (uint256, uint256, uint256, uint256) {
        PriceData memory priceData = pricesData[_roundId];
        return (
            _roundId, 
            priceData.price, 
            priceData.latestPrice, 
            priceData.timestamp
        );
    }
}

File 2 of 3 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 3 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_xOracle","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"uint256","name":"_decimals","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"xOracle","type":"address"}],"name":"SetXOracle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"latestPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"UpdatePrice","type":"event"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundId","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pricesData","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"latestPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_xOracle","type":"address"}],"name":"setXOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063d55f92731161008c578063e757223011610066578063e757223014610225578063eb4344d71461026f578063f2fde38b14610282578063f7d975771461029557600080fd5b8063d55f9273146101af578063d8cf24fd146101b8578063e2d31d9a1461021257600080fd5b8063668a0f02116100c8578063668a0f021461016e578063715018a6146101775780638205bf6a146101815780638da5cb5b1461018a57600080fd5b806306fdde03146100ef57806322fe60b81461010d578063313ce56714610157575b600080fd5b6100f76102a8565b604051610104919061063a565b60405180910390f35b61013c61011b366004610688565b60056020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610104565b61016060045481565b604051908152602001610104565b61016060065481565b61017f610336565b005b61016060075481565b6000546001600160a01b03165b6040516001600160a01b039091168152602001610104565b61016060035481565b6006546000818152600560209081526040918290208251606081018452815480825260018301549382018490526002909201549301839052915b604080519485526020850193909352918301526060820152608001610104565b600154610197906001600160a01b031681565b6101f2610233366004610688565b60008181526005602090815260409182902082516060810184528154808252600183015493820184905260029092015493018390529293909190565b61017f61027d3660046106a1565b61034a565b61017f6102903660046106a1565b6103f3565b61017f6102a33660046106d1565b61046c565b600280546102b5906106f3565b80601f01602080910402602001604051908101604052809291908181526020018280546102e1906106f3565b801561032e5780601f106103035761010080835404028352916020019161032e565b820191906000526020600020905b81548152906001019060200180831161031157829003601f168201915b505050505081565b61033e610590565b61034860006105ea565b565b610352610590565b6001600160a01b03811661039f5760405162461bcd60e51b815260206004820152600f60248201526e1859191c995cdcc81a5b9d985b1a59608a1b60448201526064015b60405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f6c48a60c0375177ff24c8b5b13defd76b82697ba4eb0c0f265d175ca63a64dba9060200160405180910390a150565b6103fb610590565b6001600160a01b0381166104605760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610396565b610469816105ea565b50565b6001546001600160a01b031633146104bb5760405162461bcd60e51b81526020600482015260126024820152713c27b930b1b6329d103337b93134b23232b760711b6044820152606401610396565b60006007548211156104d357506007819055816104ea565b506006546000908152600560205260409020600101545b600680549060006104fa8361072d565b909155505060408051606080820183528582526020808301858152428486018181526006805460009081526005865288902096518755925160018701555160029095019490945560035490548551908152918201889052938101859052908101919091527fd37605941cf2403b0eed3b571758fd57ec7a4c6829d707fac05db895c662b8ee9060800160405180910390a2505050565b6000546001600160a01b031633146103485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610396565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208083528351808285015260005b818110156106675785810183015185820160400152820161064b565b506000604082860101526040601f19601f8301168501019250505092915050565b60006020828403121561069a57600080fd5b5035919050565b6000602082840312156106b357600080fd5b81356001600160a01b03811681146106ca57600080fd5b9392505050565b600080604083850312156106e457600080fd5b50508035926020909101359150565b600181811c9082168061070757607f821691505b60208210810361072757634e487b7160e01b600052602260045260246000fd5b50919050565b60006001820161074d57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212208651c9f3005d735efc066411a8a41f9aa95e6a5dbdf12a1bb5e34c12dd5a1d9764736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.