# KCC Oracle

## Overview

A blockchain oracle is a bridge between the blockchain and the real world. These oracles allow real-world data to enter the blockchain. This data could be anything from price information to weather reports. Oracles can also be bi-directional and "send" data out to the real world. With the sharp rise of various DeFi applications, a stable and reliable decentralized oracle service is key to premium DeFi projects. Hence, the arrival of KCC Oracle addresses the need for KCC-based smart contracts to access external data. Please read through them carefully and understand the underlying risks before using Oracle.

## Reliability

### Data Sources

KCC Oracle sources price data from multiple centralized exchanges (CEXs) and from the decentralized finance (DeFi) applications and aggregates the data using a weighted formula.

### Data Signing

KCC Oracle has two roles: transmitter and signer. The signer signs data, and the transmitter is responsible for transmitting the signed data up the chain. It is intended to make data tamper-proof and to improve the security and reliability of different roles addresses.

### Data Publishing

Publishing data to the blockchain happens through multi-nodes. Multi-nodes also ensure that those smart contracts that already store some data are secure and audited. Multi-node architecture can also adjust the frequency of data publishing based on the situation. For example, it can help you get accurate data during high price volatility.

### Data Monitoring

The data on the KCC Oracle is kept up to date by an independent monitoring service that works 24 hours a day, seven days a week. It fetches prices from different data sources and compares them to published blockchain data. And the KCC Oracle support team will intervene if a significant deviation is detected.

## API Reference

Oracle Aggregator periodically publishes valuable data to the Oracle network. The aggregator stores the aggregated data on a chain so that consumers can retrieve and use it in the same transaction. We recommend retrieving data sources through [`AggregatorV3Interface`](https://github.com/kcc-community/kcc-oracle/blob/main/contracts/interfaces/AggregatorV3Interface.sol) and proxy addresses.

### Functions

<table><thead><tr><th width="178" align="center">Name</th><th align="center">Descripition</th></tr></thead><tbody><tr><td align="center">decimals</td><td align="center">The number of decimals</td></tr><tr><td align="center">description</td><td align="center">The description of trading pairs</td></tr><tr><td align="center">getRoundData</td><td align="center">Get data from a specific round</td></tr><tr><td align="center">latestRoundData</td><td align="center">Get data from the latest round</td></tr><tr><td align="center">version</td><td align="center">Get the version of the aggregator</td></tr></tbody></table>

#### decimals

Get the number of decimals of the response

```solidity
function decimals() external view returns (uint8);
```

**Return values**

* RETURN: The number of decimals

#### description

Get the description of the aggregator

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

**Return values**

* RETURN: The description of trading pairs

#### getRoundData

Get the round data details for a given round ID

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

**Parameters**

* \_roundId: The round ID

**Return values**

* roundId: The round ID
* answer: The answer for this round
* startedAt: Timestamp of when the round started
* updatedAt: Timestamp of when the round was updated
* answeredInRound: The round ID in which the answer was computed

#### latestRoundData

Get the price from the latest round

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

**Return values**

* roundId: The round ID
* answer: The price
* startedAt: Timestamp of when the round started
* updatedAt: Timestamp of when the round was updated
* answeredInRound: The round ID of the round in which the answer was computed

#### version

Get the version of the aggregator

```solidity
function version() external view returns (uint256);
```

**Return values**

* RETURN: The version of the aggregator

## Contract Address

**KCC Mainnet Feed addresses**

<table><thead><tr><th width="153" align="center">Pair (Base/Quote)</th><th width="107" align="center">Decimals	</th><th width="112" align="center">Deviation</th><th width="116" align="center">Heartbeat</th><th width="199" align="center">Data Feed Contract (Proxy Address)</th></tr></thead><tbody><tr><td align="center">BTC/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">2m</td><td align="center"><mark style="color:green;">0xFAce3f85602A8dc013217b61a97a9AFE7B2F276F</mark></td></tr><tr><td align="center">ETH/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">2m</td><td align="center"><mark style="color:green;">0x72E10386eBE0E3175f62BF3Edfc9A64aC3c5918a</mark></td></tr><tr><td align="center">KCS/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">20m</td><td align="center"><mark style="color:green;">0xAFC9c849b1a784955908d91EE43A3203fBC1f950</mark></td></tr><tr><td align="center">SKCS/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">20m</td><td align="center"><mark style="color:green;">0xdB4b34b3Fc38D828DFE5D9D34CcF0f5f15c09684</mark></td></tr><tr><td align="center">USDT/USD</td><td align="center">8</td><td align="center">0.1%</td><td align="center">30m</td><td align="center"><mark style="color:green;">0x001c1a168ba2a36D01a99542740C375c51615161</mark></td></tr><tr><td align="center">USDC/USD</td><td align="center">8</td><td align="center">0.1%</td><td align="center">30m</td><td align="center"><mark style="color:green;">0x1A165db46d431804B0082eb5BEbc307ffb97e31b</mark></td></tr></tbody></table>

**KCC Testnet Feed addresses**

<table><thead><tr><th width="142" align="center">Pair (Base/Quote)</th><th width="106" align="center">Decimals	</th><th width="114" align="center">Deviation</th><th width="122" align="center">Heartbeat</th><th align="center">Data Feed Contract (Proxy Address)</th></tr></thead><tbody><tr><td align="center">BTC/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">2m</td><td align="center">0xBb3423a913a9a69aD7Dba09B62abdFDE4643BAe4</td></tr><tr><td align="center">ETH/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">2m</td><td align="center">0x22337a9a305E081c0C801dd7B7b8eCF4966660bB</td></tr><tr><td align="center">KCS/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">20m</td><td align="center">0xae3DB39196012a7bF6D38737192F260cdFE1E7Ec</td></tr><tr><td align="center">SKCS/USD</td><td align="center">8</td><td align="center">0.2%</td><td align="center">20m</td><td align="center">0xAAf1A426D4b5D57c55E67f6eCc2918c698D94359</td></tr><tr><td align="center">USDT/USD</td><td align="center">8</td><td align="center">0.1%</td><td align="center">30m</td><td align="center">0x2bE470B8BD3CF5655dcC666CDe37E3E4D6cf3168</td></tr><tr><td align="center">USDC/USD</td><td align="center">8</td><td align="center">0.1%</td><td align="center">30m</td><td align="center">0x91b66dAd926FaC824da9390D1aF6f68db391A5c0</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://docs.kcc.io/developers/oracles/kcc-oracle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
