> For the complete documentation index, see [llms.txt](https://docs.bifrostnetwork.com/kr/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/kr/developer-documentations/cross-chain-transaction-and-oracle-api/price-oracle-contract-api.md).

# 가격 오라클 컨트랙트 API

## 설명

바이프로스트 네트워크의 주요 장점 중 하나는 바로 네이티브 가격 오라클입니다. 이 오라클은 중앙화 거래소 (CEX)와 다른 네트워크의 탈중앙화 거래소 (DEX)로부터 광범위한 디지털 자산 가격을 제공합니다. 바이프로스트 네트워크는 CCCP (크로스체인 커뮤니케이션 프로토콜)가 지원하는 자산에 대한 가격 오라클을 모든 개발자에게 공개적으로 제공하고 있습니다. 많은 디앱 개발자들이 우리 네트워크를 통해 이러한 이점을 누리기를 바랍니다.

학습 곡선을 최소화하기 위해, 저희 오라클 서비스는 Chainlink와 호환되는 인터페이스를 제공하는 추상화 계층을 포함하고 있습니다. 이러한 설계는 개발자들이 적응하는 데 필요한 시간을 줄여줄 뿐만 아니라, 이미 Chainlink 환경에 익숙한 개발자들에게는 매끄러운 통합을 가능하게 합니다.

다음 섹션에서는 바이프로스트의 가격 오라클을 활용하는 방법에 대해 설명하겠습니다.

## 가격 피드 컨트랙트

### decimals()

특정 자산 (예: ETH의 USD 가격)의 USD 가격 소수점 이하 자릿수를 반환합니다.

#### **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>특정 자산에 대한 소수점 자릿수 (현재 USD만 지원)</td></tr></tbody></table>

### description()

특정 오라클 피더(예: 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>특정 오라클 피더의 유형</td></tr></tbody></table>

### version()

특정 오라클 피드 컨트랙트의 버전을 반환합니다.

#### 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>특정 오라클 피드 컨트랙트의 버전.</td></tr></tbody></table>

### getRoundData(\_roundId)

이전 라운드의 가격 정보와 해당 업데이트의 타임스탬프를 반환합니다.

#### 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>원하는 가격 정보의 라운드 ID.</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>라운드 ID.</td></tr><tr><td>answer</td><td>int256</td><td>이 라운드의 가격 정보.</td></tr><tr><td>startedAt</td><td>uint256</td><td>라운드가 시작된 시점의 타임스탬프.</td></tr><tr><td>updatedAt</td><td>uint256</td><td>라운드가 업데이트된 시점의 타임스탬프.</td></tr><tr><td>answeredInRound</td><td>uint80</td><td>답변은 여러 라운드를 거쳐 계산될 수 있습니다.</td></tr></tbody></table>

### latestRoundData()

가장 최신 가격 정보와 해당 업데이트의 타임스탬프를 반환합니다.

#### 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>라운드 ID.</td></tr><tr><td>answer</td><td>int256</td><td>이 라운드의 가격 정보.</td></tr><tr><td>startedAt</td><td>uint256</td><td>라운드가 시작된 시점의 타임스탬프.</td></tr><tr><td>updatedAt</td><td>uint256</td><td>라운드가 업데이트된 시점의 타임스탬프.</td></tr><tr><td>answeredInRound</td><td>uint80</td><td>답변은 여러 라운드를 거쳐 계산될 수 있습니다.</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;
    }
}
```
