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