简体   繁体   中英

Chainlink.Request doesn't have `add` function

Now I am using this dependency: "@chainlink/contracts": "^0.1.7" and solc v0.8

Facing this issue: 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.

...
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.

I ran into the same issue and contacted Avneet from the Chainlink team. Turns out this is caused by a change in the Solidity language starting from v0.7:

Breaking change in v0.7:

using A for B only affects the contract it is mentioned in. Previously, the effect was inherited. Now, you have to repeat the using statement in all derived contracts that make use of the feature. https://docs.soliditylang.org/en/v0.7.0/070-breaking-changes.html

Therefore, you need to add using Chainlink for Chainlink.Request; to the top of your contract, like so:

contract MyClient {
  using Chainlink for Chainlink.Request;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM