[英]Call chainlink from other smart contract?
I need to get a value from an array which I read through a chainlink oracle.我需要从通过链环 oracle 读取的数组中获取一个值。 So far so good, but I need that value in another contract to make use of it, how could I make this happen?
到目前为止一切顺利,但我需要在另一个合同中使用该值才能使用它,我怎么能做到这一点?
Also, how can I make a combined payment, when someone buys one Service, the money would also be used to pay the gas for the Chainlink fee?另外,我如何进行合并付款,当有人购买一项服务时,这笔钱也将用于支付 Chainlink 费用的汽油费?
thanks!谢谢!
To read a value from a Chainlink data feed, you need to pass a feed's address to the AggregatorV3Interface.sol
interface.要从 Chainlink 数据提要中读取值,您需要将提要的地址传递给
AggregatorV3Interface.sol
接口。
AggregatorV3Interface dataFeed = AggregatorV3Interface(0x9326....);
You then can call the interface's latestRoundData()
function, which returns a tuple of values that contain the information you requested.然后,您可以调用接口的
latestRoundData()
function,它会返回一个包含您请求的信息的值元组。 For an example price feed:对于一个示例价格馈送:
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
See https://docs.chain.link/docs/get-the-latest-price/ for more details.有关详细信息,请参阅https://docs.chain.link/docs/get-the-latest-price/ 。
When you say combined payment, what do you mean?当您说联合付款时,您是什么意思? If the Chainlink data feed call (as above) is called during a transaction, that transaction's gas will be used to pay for the computation.
如果在交易期间调用 Chainlink 数据馈送调用(如上),则该交易的气体将用于支付计算费用。 So if a user buys a service and sends gas with that call, and then in that call the data feed is called, the original sender's gas will be used to call the data feed method.
因此,如果用户购买服务并通过该调用发送 gas,然后在该调用中调用 data feed,原始发送者的 gas 将用于调用 data feed 方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.