简体   繁体   English

从其他智能合约调用chainlink?

[英]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.

相关问题 如何用其他合约为 Chainlink 智能合约注资? - How to fund Chainlink smart contract with other contract? 从 mai.net(以太坊)上的其他智能合约调用 function 部署合约是否可行(就 gas 成本而言)? - Is it feasible (In terms of gas cost) to call a function of deployed contract from other smart contract on mainnet (ethereum)? 从智能合约安排通话功能 - Schedule call function from smart contract Solidity - 如何从外部合同中调用智能合约实例? - Solidity - How to call smart contract instances from external contract? 如何从合约地址和abi获取智能合约调用地址 - How to get smart contract call address from contract address and abi 如何在我的智能合约中使用 chainlink VRF v1? - How to use chainlink VRF v1 in my smart contract? 通过字节从新的智能合约调用已部署的智能合约功能。 - Call deployed smart contract function from new smart contract via bytes.? 从我的智能合约中调用已部署的智能合约的功能 - Call function of a already deployed smart contract from within my smart contract 从其他智能合约铸造新的 ERC20 代币 - Mint new ERC20 token from other smart contract 使用 Operator.sol 合约的 Solidity 智能合约未调用 Chainlink 作业 - Chainlink job is not being called by the Solidity Smart Contract using Operator.sol contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM