Chainlink Developers

Welcome to the Chainlink documentation site. You'll find comprehensive guides and documentation to help you start working with Chainlink as quickly as possible, as well as support if you get stuck. Click here for an introductory walkthrough on how to create a Chainlink request on the Ropsten test network!

Contract Creators

Using parameters with an External Adapter

As a contract creator, using an external adapter is no different than creating a request for any other job spec. You will simply need to know which parameters are supported by the adapter. for example, our BraveNewCoin Chainlink requires that the parameters endpoint, coin, and market are used. Notice the method below uses run.add to create a run parameter for each required value.

function requestMWAPrice(string _coin, string _market)
  public
  onlyOwner
  returns (bytes32 requestId) 
{
  ChainlinkLib.Run memory run = newRun(SPEC_ID, this, this.fulfill.selector);
  run.add("endpoint", "mwa-historic");
  run.add("coin", _coin);
  run.add("market", _market);
  run.add("copyPath", "data.-1.1");
  run.addInt("times", 100);
  requestId = chainlinkRequest(run, LINK(1));
}

Using the Copy adapter with an External Adapter

The Copy adapter allows for the same functionality of the JSONParse adapter but for getting data from the external adapter's response.

For example, if an adapter returns JSON data like what is below:

{
    "firstValue": "SomeValue",
    "details": {
        "close": "100",
        "open": "110",
        "current": "111"
    },
    "other": "GetData"
}

And you wanted the value in the field "open", you would specify the path for the adapter to walk through the JSON object to your desired field.

"copyPath": ["details", "open"]

In Solidity, this would look like:

string[] memory path = new string[](2);
path[0] = "details";
path[1] = "open";
run.addStringArray("copyPath", path);

Or you can use dot-notation to simplify it:

run.add("copyPath", "details.open");