0

undeclared identifier

copied contract from link docs https://docs.chain.link/docs/jobs/types/direct-request/

import "https://github.com/smartcontractkit/chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract MyClient is ChainlinkClient {
    function doRequest(uint256 _payment) public {
        Chainlink.Request memory req = buildChainlinkRequest(specId, address(this), this.fulfill.selector);
        req.add("fetchURL", "https://datafeed.xyz/eth");
        req.add("jsonPath", "data,result");
        sendChainlinkRequest(req, _payment);
    }

    function fulfill(bytes32 requestID, uint256 answer) public {
        // ...
    }
}

trying to make a simple http get request to my API/URL https://ljiigsoedk.execute-api.ca-central-1.amazonaws.com/default/wildfire..

but without modifying any code i get undeclared identifier Chainlink.Request memory req = buildChainlinkRequest(specId, address(this), this.fulfill.selector); with >>specID<< being pointed at by angry remix compiler

my nodes job is

type = "directrequest"
schemaVersion = 1
name = "example eth request event spec"
contractAddress = "0xCcbB32b820799DDCadCFeEE472B9804a1397005E"
maxTaskDuration = "0s"
observationSource = """
    ds          [type="http" method=GET url="https://ljiigsoedk.execute-api.ca-central-1.amazonaws.com/default/wildfire"]
    ds_parse    [type="jsonparse" path="FIRE_NUMBE"]
    

    ds -> ds_parse 
"""
externalJobID = "37ab8f92-090e-4d23-9b08-96495f96899f"

haven't made it that far yet, im guessing i am following the right steps for making this happen.. if not please let me know what i am doing wrong..

or is this blob what i should use for the job -.-

// First, we parse the request log and the CBOR payload inside of it
decode_log  [type="ethabidecodelog"
             data="$(jobRun.logData)"
             topics="$(jobRun.logTopics)"
             abi="SomeContractEvent(bytes32 requestID, bytes cborPayload)"]

decode_cbor [type="cborparse"
             data="$(decode_log.cborPayload)"]

// Then, we use the decoded request parameters to make an HTTP fetch
fetch [type="http" method=GET url="$(decode_cbor.fetchURL)"]
parse [type="jsonparse" path="$(decode_cbor.jsonPath)" data="$(fetch)"]

// Finally, we send a response on-chain.
// Note that single-word responses automatically populate
// the requestId.
encode_response [type="ethabiencode"
                 abi="(uint256 data)"
                 data="{\\"data\\": $(parse) }"]

encode_tx       [type="ethabiencode"
                 abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
                 data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_mwr)}"
                 ]

submit_tx  [type="ethtx" to="0x613a38AC1659769640aaE063C651F48E0250454C" data="$(encode_tx)"]

decode_log -> decode_cbor -> fetch -> parse -> encode_response -> encode_tx -> submit_tx

2 Answers 2

2

It's likely that one of your typings is wrong. You'll need a bytes32 for specId for example. Add next lines to your contract code above doRequest function

using Chainlink for Chainlink.Request;

address private oracle;
bytes32 private specId;
uint256 private fee;

constructor() {
   setPublicChainlinkToken();
   oracle = 0xCcbB32b820799DDCadCFeEE472B9804a1397005E; // oracle address from posted job, replace if different
   specId = "37ab8f92090e4d239b0896495f96899f"; // jobId from posted job, replace if different
   fee = 0.1 * 10 ** 18; // your fee goes here, this is default value
}
0

From the documentation for buildChainlinkRequest the first parameter is a bytes32.

There's an example in the documentation

bytes32 jobId = "493610cff14346f786f88ed791ab7704";
1
  • yep you're right, specId is the jobId passed as a string Nov 19, 2021 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.