【问题标题】:Chainlink.Request doesn't have `add` functionChainlink.Request 没有 `add` 功能
【发布时间】:2021-06-16 10:18:44
【问题描述】:

现在我正在使用这个依赖:"@chainlink/contracts": "^0.1.7" 和 solc v0.8

面对这个问题:Member "add" not found or not visible after argument-dependent lookup in struct Chainlink.Request memory

据说Chainlink.Request没有add功能...请告诉我如何解决它。

...
import "@chainlink/contracts/src/v0.8/dev/ChainlinkClient.sol";

contract ContractName is Ownable, ChainlinkClient {
    constructor() {
         setPublicChainlinkToken();
    }

    function requestData(
        address _oracle,
        bytes32 _jobId,
        string memory _endpoint,
        string memory _round,
        string memory _seasonId
    ) public {
        Chainlink.Request memory req =
            buildChainlinkRequest(_jobId, address(this), this.fulfill.selector);
        req.add(req, "endpoint", _endpoint);
        req.add(req, "round", _round);
        req.add(req, "season_id", _seasonId);

        sendChainlinkRequestTo(_oracle, req, fee_);
    }

enter image description here

【问题讨论】:

    标签: blockchain solidity ether chainlink


    【解决方案1】:

    编辑:总是对仍在开发分支中的合约感到厌倦。话虽如此,v0.8 Chainlink Client 现在已经脱离了开发分支,这个答案仍然是相关的。

    我遇到了同样的问题,并联系了 Chainlink 团队的 Avneet。原来这是由从 v0.7 开始的 Solidity 语言的变化引起的:

    v0.7 中的重大变化:

    将 A 用于 B 只会影响其中提到的合约。以前,效果是继承的。现在,您必须在所有使用该功能的派生合约中重复 using 语句。 https://docs.soliditylang.org/en/v0.7.0/070-breaking-changes.html

    因此,您需要添加 using Chainlink for Chainlink.Request; 到合同的顶部,如下所示:

    contract MyClient {
      using Chainlink for Chainlink.Request;
    

    【讨论】:

      猜你喜欢
      • 2010-11-29
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 2020-09-09
      相关资源
      最近更新 更多