简体   繁体   English

Chainlink.Request 没有 `add` 功能

[英]Chainlink.Request doesn't have `add` function

Now I am using this dependency: "@chainlink/contracts": "^0.1.7" and solc v0.8现在我正在使用这个依赖项: "@chainlink/contracts": "^0.1.7" 0.1.7 "@chainlink/contracts": "^0.1.7"和 solc v0.8

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

It's saying that Chainlink.Request doesn't have add function... please let me know how to fix it.据说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在此处输入图片说明

Edit: Always be weary of contracts still in the dev branch.编辑:总是对仍在开发分支中的合同感到厌烦。 With that being said, v0.8 Chainlink Client is now out of the dev branch and this answer is still relevant.话虽如此,v0.8 Chainlink Client 现在不在 dev 分支中,这个答案仍然相关。

I ran into the same issue and contacted Avneet from the Chainlink team.我遇到了同样的问题,并联系了 Chainlink 团队的 Avneet。 Turns out this is caused by a change in the Solidity language starting from v0.7:原来这是由从 v0.7 开始的 Solidity 语言的变化引起的:

Breaking change in v0.7: v0.7 中的重大变化:

using A for B only affects the contract it is mentioned in. Previously, the effect was inherited.对 B 使用 A 只会影响它提到的合约。以前,效果是继承的。 Now, you have to repeat the using statement in all derived contracts that make use of the feature.现在,您必须在所有使用该功能的派生合约中重复 using 语句。 https://docs.soliditylang.org/en/v0.7.0/070-breaking-changes.html https://docs.soliditylang.org/en/v0.7.0/070-break-changes.html

Therefore, you need to add using Chainlink for Chainlink.Request;因此,需要using Chainlink for Chainlink.Request;添加using Chainlink for Chainlink.Request; to the top of your contract, like so:到合同的顶部,如下所示:

contract MyClient {
  using Chainlink for Chainlink.Request;

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

相关问题 构建chainlink节点-以太坊ChainID与chainlink config.ChainID不匹配 - Building a chainlink node - ethereum ChainID doesn't match chainlink config.ChainID 如何深入了解链链接 req.add(“path”) 请求的 JSON 主体? 添加 2+ 路径 - How to get deeper in the JSON body of a chainlink req.add(“path”) request? Add 2+ paths 如何调用 getLatestPrice function Chainlink 喂价 - How to Call getLatestPrice function Chainlink Price Feed 为什么 Chainlink oracle function 调用失败? - Why is Chainlink oracle function call failing? 运行 Chainlink 节点 - 无法连接到数据库 - Running a Chainlink Node - Can't connect to database Solidity有HTTP请求功能吗? - Does Solidity have HTTP request function? Chainlink vrf v2 请求 gas 费用金额 - Chainlink vrf v2 request gas fee amount chainlink 是否有可靠的方法来验证存储在 IPFS 上的 hash 后面的文件的大小/格式? - Does chainlink have a reliable way to verify the size/format of a file behind a hash stored on IPFS? 当我从 chainlink VRF v1 调用 getRandomNumber() function 时交易失败 - transaction fails when I call getRandomNumber() function from chainlink VRF v1 如何自动执行 ChainLink 作业以调用智能合约 function,要求调用者是给定的管理员地址? - How to automate a ChainLink Job to call a smart-contract function that requires the caller to be a given admin address?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM