I am trying to understand Chainlink, and I am running into a wall. I found this tutorial, which explains how I can create a job spec using JSON.

The tutorial explains that you can specify the url, path and multiply value yourself, while the official Chainlink documentation places these in the JSON, and does not require these to be added in the smart contract code.

How does Chainlink decide which parameter to place where? What if you have multiple HTTPGet tasks that take parameters?


If you are using, for example, the httpget adapter, you can place this in EITHER the JSON job spec, OR you can add it to your smart contract code.

Here is an example of a smart contract using the req.add feature:

// Creates a Chainlink request with the bytes32 job and returns the requestId
function requestEthereumLastMarket(bytes32 _jobId) public returns (bytes32 requestId) {
  // newRequest takes a JobID, a callback address, and callback function as input
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.fulfillEthereumLastMarket.selector);
  // Adds a URL with the key "get" to the request parameters
  req.add("get", "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD");
  // Adds a dot-delimited JSON path with the key "path" to the request parameters
  req.add("path", "RAW.ETH.USD.LASTMARKET");
  // Sends the request with 1 LINK to the oracle contract
  requestId = sendChainlinkRequest(req, 1 * LINK);

The req.add basically adds these parameters to the json spec of that job instance. If you have both the json job spec AND the smart contract defining the http.get adapter, the job spec will override the smart contracts.

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.