简体   繁体   English

Chainlink 消费者合约中回调地址的用途是什么?

[英]What is the use of callback addresses in a Chainlink Consumer contract?

I have a question about the RSK integration (specifically about how callback addresses are used) https://github.com/smartcontractkit/chainlink-RSK/blob/master/test-runner/src/contracts/Consumer.sol我有一个关于 RSK 集成的问题(特别是关于如何使用回调地址) https://github.com/smartcontractkit/chainlink-RSK/blob/master/test-runner/src/contracts/Consumer.sol

 function requestRIFPriceByCallback(uint256 _payment, address _callback) public {
    Chainlink.Request memory req = buildChainlinkRequest(specId, _callback, this.fulfill.selector);
    req.add("get", "https://api.liquid.com/products/580");
    req.add("path", "last_traded_price");
    req.addInt("times", 100000000);
    sendChainlinkRequest(req, _payment);
  }

https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.4/tests/Consumer.sol https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.4/tests/Consumer.sol

function requestEthereumPrice(string _currency) public {
    Chainlink.Request memory req = buildChainlinkRequest(specId, this, this.fulfill.selector);
    req.add("get", "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR,JPY");
    string[] memory path = new string[](1);
    path[0] = _currency;
    req.addStringArray("path", path);
    sendChainlinkRequest(req, ORACLE_PAYMENT);
  }

These are from Consumer.sol (above from RSK and below from original) Why does the RSK consumer require a callback address and what does that do/how does it work?这些来自 Consumer.sol(上面来自 RSK,下面来自原始) 为什么 RSK 消费者需要回调地址,它有什么作用/它是如何工作的?

Both of these functions have callback addresses.这两个函数都有回调地址。 You'll see in the second method they just use 'this'.您会在第二种方法中看到他们只使用“this”。 The callback address is a parameter in the 'buildChainlinkRequest' function.回调地址是 'buildChainlinkRequest' function 中的一个参数。 It specifies which contract to return the data to.它指定将数据返回到哪个合约。 That combined with the function selector lets you pick which contract and function you want to return your data to.结合 function 选择器,您可以选择要将数据返回到的合约和 function。

The 2nd method doesn't have a callback address because it's set to 'this'.第二种方法没有回调地址,因为它设置为“this”。 The first function lets you pick.第一个 function 让你挑选。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的智能合约中使用 chainlink VRF v1? - How to use chainlink VRF v1 in my smart contract? Chainlink 节点:交易未决时该怎么办? - Chainlink node: What to do when transactions are pending? 我应该如何使用chainlink keeper - how should i use chainlink keeper Waves智能合约的地址与以太坊中的地址相似吗? - Is the Waves smart contract has similar addresses as in Ethereum? 退还所有在 Solidity 合同中输入的地址 - Refund all addresses entered on solidity contract “VM Exception while processing transaction: revert”,当运行chainlink节点并尝试部署TestnetConsumer合约时? - "VM Exception while processing transaction: revert", when running a chainlink node and try to deploy TestnetConsumer contract? 什么是用于创建程序可用于执行合同付款的转账账户的 Solana 模式? - What is the Solana pattern for creating a transfer account the program can use to execute a contract payment? 如何使用solidity有效地将大量地址存储在智能合约中? - How to efficiently store large amount of addresses in a smart contract using solidity? web3.js中包含合同的Contract.at的替代功能是什么? - What is the replacement function for Contract.at in web3.js for including a contract? 以去中心化方式从 Chainlink 访问代币历史价格数据的最佳方式是什么? - What is the best way to access historical price data from Chainlink on a token in a decentralised manner?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM