1

I am following the documentation from the Chainlink site, and I am attempting to make an API call. The main issue is I'm not sure what "address" is referring too. I am using remix in solidity v0.6

  function requestEthereumPrice(address _address) 
    public
    onlyOwner
  {
    // newRequest takes a JobID, a callback address, and callback function as input
    Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(JOB_ID), address(this), this.fulfill.selector);
    // Adds a URL with the key "get" to the request parameters
    req.add("get", "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD");
    // Uses input param (dot-delimited string) as the "path" in the request parameters
    req.add("path", "USD");
    // Adds an integer with the key "times" to the request parameters
    req.addInt("times", 100);
    // Sends the request with the amount of payment specified to the oracle

    sendChainlinkRequestTo(_address, req, ORACLE_PAYMENT);
  }

1 Answer 1

0

Welcome to Stack Overflow!

address is going to be the address of a chainlink node that can serve the httpget job. requestEthereumPrice is the function that you can call from one of the buttons in your remix.

Since every job needs to go through a Chainlink node, you'll have to enter the address of a Chainlink node oracle, this will be where your API call is routed through. If you don't have your own node, you can do a quick query on Linkpool's market.link for httpget jobs, and use both the oracle address, and job address supplied.

It looks like in your specific case, you have the JOB_ID already, and just need the address of that specific oracle that hosts that JOB_ID.

One thing that is important to note is that you are not doing an API call from the contract literally. Since everything on chain is deterministic, we have the node make the call, place that data on chain, and then your smart contract is actually calling the data from the oracle. This way, if the whole chain were replayed, you'd still get all the same answers.

Check out this post for more information, and you can run through documentation on making API calls, or read the article on connecting your smart contract to APIs.

The image below shows where you would enter the data and the buttons you'd press.

The buttons are where you can make calls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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