4

预言机

 3 years ago
source link: https://learnblockchain.cn/question/1978
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Chainlink预言机问题 | 登链社区 | 技术问答

5 Chainlink预言机问题

有两个疑惑。

第一个,chainlink的返回的这5个字段分别代表什么意思,在文档中没找到解释:

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

第二个,chainlink我看了下相应的交易对信息,如果我想要将100cny计算出需要多少ETH的话,那么就需要经过:

首先,查询 CNY / USD 的价格,然后再查询 USD / ETH 的价格。然后才能给出100CNY能兑换多少ETH。这样的前后依赖的情况下,该怎么确保一次交易的成功呢?

目前我的想法是,前端用户提交了100CNY,且提交有预言机给的CNY/USD的roundId,和 USD/ETH的roundId,然后在合约中进行验证。结合预言机给的startedAt做一个时间范围限制,比如说超过10分钟的roundId就视作无效。不知道这个思路是否可行?这个思路是否太复杂了,是否有跟简单的方法?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK