> For the complete documentation index, see [llms.txt](https://docs.bifrostnetwork.com/bifrost-network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bifrostnetwork.com/bifrost-network/developer-documentations/cross-chain-transaction-and-oracle-api/price-oracle-contract-api.md).

# Price Oracle Contract API

## Description

One of the key advantages of the Bifrost Network is its native price oracle, which offers a wide range of digital asset prices sourced from centralized exchanges (CEXs) and decentralized exchanges (DEXs) on other networks. We have made the price oracle for CCCP-supported assets publicly available to all developers on the Bifrost Network. We hope many DApp developers will enjoy these benefits through our network.

To minimize the learning curve, our oracle service includes an abstraction layer that provides an interface compatible with Chainlink's. This design choice not only reduces the time needed for developers to adapt but also enables seamless integration for those already familiar with Chainlink's environment.&#x20;

In the following sections, we will explain how to utilize Bifrost's price oracle.

## Price Feed Methods

### decimals()

Returns USD price decimals for a specific asset (e.g., the USD price of ETH).

#### **Return values**

<table><thead><tr><th width="111">Name</th><th width="95">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>uint8</td><td>The decimals (now only USD support)  for a specific asset</td></tr></tbody></table>

### description()

Return the type of a specific oracle feeder (e.g., ETH/USD)

#### Return values

<table><thead><tr><th width="111">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>string</td><td>The type of a specific oracle feeder </td></tr></tbody></table>

### version()

Return the version of a specific oracle feed contract.

#### Return values

<table><thead><tr><th width="111">Name</th><th width="99">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>uint256</td><td>The version of a specific oracle feed contract. </td></tr></tbody></table>

### getRoundData(\_roundId)

Return the price information from the previous round along with the timestamp of that update.

#### Parameters

<table><thead><tr><th width="130">Name</th><th width="99">Type</th><th>Description</th></tr></thead><tbody><tr><td>_roundId</td><td>uint8</td><td>The round ID of desired price information. </td></tr></tbody></table>

#### Return values

<table><thead><tr><th width="192">Name</th><th width="99">Type</th><th>Description</th></tr></thead><tbody><tr><td>roundId</td><td>uint80</td><td>The round ID.</td></tr><tr><td>answer</td><td>int256</td><td>The price information for this round.</td></tr><tr><td>startedAt</td><td>uint256</td><td>The timestamp of when the round started.</td></tr><tr><td>updatedAt</td><td>uint256</td><td>The timestamp of when the round was updated.</td></tr><tr><td>answeredInRound</td><td>uint80</td><td>The answers could take multiple rounds to be computed.</td></tr></tbody></table>

### latestRoundData()

Return the latest price information along with the timestamp of the most recent update.

#### Return values

<table><thead><tr><th width="192">Name</th><th width="99">Type</th><th>Description</th></tr></thead><tbody><tr><td>roundId</td><td>uint80</td><td>The round ID.</td></tr><tr><td>answer</td><td>int256</td><td>The price information for this round.</td></tr><tr><td>startedAt</td><td>uint256</td><td>The timestamp of when the round started.</td></tr><tr><td>updatedAt</td><td>uint256</td><td>The timestamp of when the round was updated.</td></tr><tr><td>answeredInRound</td><td>uint80</td><td>The answers could take multiple rounds to be computed.</td></tr></tbody></table>

## Price Feed Contract Interface

```solidity
interface IAccessControlledOffchainAggregator {
  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external pure 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
  );
}
```

## Price Feed Contract Address

<table><thead><tr><th width="170">Asset/Fiat Type</th><th>Contract Address (mainnet/testnet)</th></tr></thead><tbody><tr><td>ETH/USD</td><td><strong>mainnet</strong>: <code>0x0427d2908E45FAfD65F56a6A6E2095461e70A3d6</code><br><strong>testnet</strong>: <code>0x786cA38641bD2eE6f4c9397056F9CF9d9C893eEA</code></td></tr><tr><td>USDC/USD</td><td><strong>mainnet</strong>: <code>0x2FFc2e7C4c280eb82A13972cCA30719F9365746F</code><br><strong>testnet</strong>: <code>0x9Fa06A8f3454b902b4ecdaBB6eBC8F56CC536609</code></td></tr><tr><td>BNB/USD</td><td><strong>mainnet</strong>: <code>0x1Eda422B45b279c8C280B510cbf4BDFB671985c0</code><br><strong>testnet</strong>: <code>0x590A94102B03b10d4aDF8bfc83aCC556dc9745E5</code></td></tr><tr><td>MATIC/USD</td><td><strong>mainnet</strong>: <code>0x59C75485126Ac9a90609E7Fe5D6c513396ED503d</code><br><strong>testnet</strong>: <code>0x534Fa69E2616444B5DFB940f3a893D8183fEDcD7</code></td></tr><tr><td>BIFI/USD</td><td><strong>mainnet</strong>: <code>0xc97D3b8d03ec813b760C8A471F3c8393e4F91506</code><br><strong>testnet</strong>: <code>0x42acD3003fA8b870999573071427C64A90146991</code></td></tr><tr><td>BFC/USD</td><td><strong>mainnet</strong>: <code>0x77397a130c169702Ff007682630eCAa5caB23791</code><br><strong>testnet</strong>: <code>0xEF746B668880f83F06245245017B31523e485Df8</code></td></tr><tr><td>USDT/USD</td><td><strong>mainnet</strong>: <code>0xd8653315Dc63128AA8428C6Ae12E50b5E77156AC</code><br><strong>testnet</strong>: <code>0xfdcC92216E7236E6f0A2033B1d63D3505369945b</code></td></tr><tr><td>DAI/USD</td><td><strong>mainnet</strong>: <code>0xF2385A5DDa77fF9731F661aA44f6b4398A97A1cd</code><br><strong>testnet</strong>: <code>0x4842D3a8c29fABfB971AeD8675262c16b71ef2Dd</code></td></tr><tr><td>WBTC/USD</td><td><strong>mainnet</strong>: <code>0xc1596ece7e801125D507f0815e7070Aa97D3645e</code><br><strong>testnet</strong>: <code>0x1aF3595Ba40EAb3481f19245E5a0F09018e85Aa4</code></td></tr><tr><td>BTCB/USD</td><td><strong>mainnet</strong>: <code>0x40c8BB8036351EF29b41ea8AFEbA76ac2d8A96bF</code><br><strong>testnet</strong>: <code>0x0B2C85312E35829e714Fef01efAD6d2718e3c227</code></td></tr></tbody></table>

## Example: ETH/USD price oracle (testnet)

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IAccessControlledOffchainAggregator {
  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external pure 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
  );
}

contract ChainlinkPriceOracle {
    IAccessControlledOffchainAggregator internal priceFeed;

    constructor() {
        // ETH / USD price oracle address (testnet)
        priceFeed = IAccessControlledOffchainAggregator(0x786cA38641bD2eE6f4c9397056F9CF9d9C893eEA);
    }

    function getLatestPrice() public view returns (int) {
        (
            uint80 roundID,
            int price,
            uint startedAt,
            uint timeStamp,
            uint80 answeredInRound
        ) = priceFeed.latestRoundData();
        // for ETH / USD price is scaled up by 10 ** 8
        return price / 1e8;
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bifrostnetwork.com/bifrost-network/developer-documentations/cross-chain-transaction-and-oracle-api/price-oracle-contract-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
