Search code examples
chainlink

Member "add" not found or not visible after argument-dependent lookup in struct Chainlink.Request memory


I am creating nft smart contract and using chainlinkClient.sol for updation of URI. chainlinkClient Version: v0.6 Error: TypeError: Member "add" not found or not visible after argument-dependent lookup in struct Chainlink.Request memory. Any Idea Why am I getting this error?

Code:

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
import "chainlink/evm-contracts/src/v0.6/ChainlinkClient.sol";
contract phoneNumber is ChainlinkClient{
    uint256 public phone_no;
    address private oracle;
    bytes32 private jobId;
    uint256 private fee;

    constructor(uint256 _initial_phone_no){
        setPublicChainlinkToken();
        oracle = 0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e;
        jobId = "6d1bfe27e7034b1d87b5270556b17277";
        fee = 0.1 * 10 ** 18; // 0.1 LINK
        phone_no = _initial_phone_no;
    }
    
     function requestVolumeData() public returns (bytes32 requestId) 
    {
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.update_phone_no.selector);
        
        // Set the URL to perform the GET request on
        request.add("get", "http://localhost:3000/images/phone.json");
        

        request.add("path", "phone.new");
        
        // Multiply the result by 1000000000000000000 to remove decimals
        int timesAmount = 10**18;
        request.addInt("times", timesAmount);
        
        // Sends the request
        return sendChainlinkRequestTo(oracle, request, fee);
    }

    function update_phone_no(bytes32 _requestId, uint256 new_phone_no) public recordChainlinkFulfillment(_requestId)
    {
        phone_no = new_phone_no;
    }
    
    function withdrawLink() external {
        LinkTokenInterface linkToken = LinkTokenInterface(chainlinkTokenAddress());
        require(linkToken.transfer(msg.sender, linkToken.balanceOf(address(this))), "Unable to transfer");
    }
}

Solution

  • Your import statement is missing an "@" symbol. Add it to the beginning like this:

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

    Note: Also don't forget to explicitly state your constructor visibility specifier to public or internal as well.