current position:Home>Chainlink Oracle problem

Chainlink Oracle problem

2022-02-04 00:18:20 Q & A of Denglian community

There are two doubts .

first ,chainlink This returned 5 What do the two fields mean , No explanation was found in the document :

(            uint80 roundID,             int price,            uint startedAt,            uint timeStamp,            uint80 answeredInRound        ) = priceFeed.latestRoundData();

the second ,chainlink I looked at the corresponding transaction pair information , If I want to 100cny Figure out how much ETH Words , Then you need to go through :

First , Inquire about CNY / USD The price of , And then check USD / ETH The price of . Then we can give 100CNY How much can I exchange ETH. In the case of such pre and post dependence , How to ensure the success of a transaction ?

At present, my idea is , The front-end user submitted 100CNY, And submit a Oracle to CNY/USD Of roundId, and USD/ETH Of roundId, Then verify it in the contract . Combined with the Oracle startedAt Make a time limit , For example, more than 10 Minutes of roundId It is considered invalid . I don't know if this idea is feasible ? Is this idea too complicated , Is there a simple way ?




Take the answer 1:

The field explanation in the first question , First of all, you need to know that the definition of this function is the following :

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

So the fields mentioned in the question are different , It's essentially the same thing .

  • roundID, Indicates the current update round number , The update of each price pair is determined by two factors , Heartbeat time and price deviation threshold , Either of the two will trigger the next round of updates
  • price: Price data for asset pairs , In the function definition, we use answer
  • startedAt: Timestamp of the start of the round
  • timestamp: The update time of this round , Corresponding updatedAt
  • answeredInRound: Answer the calculated round number

On the second question , Two consecutive requests , Written in a contract function , As an atomic transaction is feasible .

CNY / USD price today | Chainlink

ETH / USD price today | Chainlink

Looking at the information of these two price pairs, you can see , use roundId Not necessarily feasible , Different price pairs have different information . For example, the offset of heartbeat time and price have different parameters .






Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202040018176299.html

Random recommended