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!

Building on Chainlink? Click here to get started!

Get Started

Adapters are the built-in functionality that every Chainlink node supports.

Compare

This adapter compares a user-specified value with the value from the previous adapter's result.

Parameters

  • operator: the operator used to compare values. You may use one of the following:
    • eq: Equals
    • neq: Not equals
    • gt: Greater than
    • gte: Greater than or equals to
    • lt: Less than
    • lte: Less than or equals to
  • value: the value to check against the previous adapter's result. May be a string or a number, but if the value is a string, only eq and neq may be used.

Solidity Example

req.addInt("value", 10000);
req.add("operator", "gte");

Copy

The adapter walks the copyPath specified and returns the value found at that result. If returning JSON data from an external adapter, you will need to use this adapter to parse the response.

Parameters

  • copyPath: takes an array of strings, each string being the next key to parse out in the JSON object or a single dot-delimited string.

Solidity Example

For the JSON object:

{"RAW": {"ETH": {"USD": {"LASTMARKET": "_someValue"}}}}

You would use the following for an array of strings:

string[] memory path = new string[](4);
path[0] = "RAW";
path[1] = "ETH";
path[2] = "USD";
path[3] = "LASTMARKET";
req.addStringArray("copyPath", path);

Or the following for a single dot-delimited string:

req.add("copyPath", "RAW.ETH.USD.LASTMARKET");

Job Specification Example

{
  "type": "Copy",
  "params": {
    "copyPath": [
      "RAW",
      "ETH",
      "USD",
      "LASTMARKET"
    ]
  }
}

EthBool

The adapter reads the given Boolean value and then converts it into Solidity's bool format.

Parameters

None taken.

EthBytes32

The adapter formats its input into a string and then converts it into Solidity's bytes32 format.

Parameters

None taken.

EthInt256

The adapter formats its input into an integer and then converts it into Solidity's int256 format.

Parameters

None taken.

EthTx

The adapter takes the input given and places it into the data field of the transaction. It then signs an Ethereum transaction and broadcasts it to the network. The task is only completed once the transaction's confirmations equal the MIN_OUTGOING_CONFIRMATIONS amount.

If the transaction does not confirm by the time ETH_GAS_BUMP_THRESHOLD number of blocks have passed since initially broadcasting, then it bumps the gas price of the transaction by ETH_GAS_BUMP_WEI.

Parameters

  • address: the address of the Ethereum account which the transaction will be sent to.
  • functionSelector: (optional) the function selector of the contract which the transaction will invoke. functionSelector is placed before dataPrefix and the adapter's input in the data field of the transaction.
  • dataPrefix: (optional) data which will be prepended before the adapter's input, but after the functionSelector in the transaction's data field.
  • value: (optional) data to send to the function, will append after the dataPrefix payload if it's included. Will automatically come from the previous task.

EthUint256

The adapter formats its input into an integer and then converts it into Solidity's uint256 format.

Parameters

None taken.

HttpGet

The adapter will report the body of a successful GET request to the specified get, or return an error if the response status code is greater than or equal to 400.

Parameters

  • get: takes a string containing the URL to make a GET request to.
  • headers: takes a object containing keys as strings and values as arrays of strings.
  • queryParams: takes a string or array of strings for the URL's query parameters.
  • extPath: takes a slash-delimited string or array of strings to be appended to the job's URL.

Solidity Example

req.add("get", "http://example.com");
req.add("queryParams", "firstKey=firstVal&secondKey=secondVal");
req.add("extPath", "price/BTC/USD");

Job Specification Example

{
  "type": "HttpGet",
  "params": {
    "get": "https://example.com/some-endpoint",
    "headers": {
      "X-API-Key": [
        "abc123abc123abc123abc123"
      ]
    }
  }
}

NOTE: For security, since the URL may come from an untrusted source, HTTPGet imposes some restrictions on which IPs may be fetched. Local network and multicast IPs are disallowed by default and attempting to connect will result in an error.

If you really must access one of these IPs, you can use the HTTPGetWithUnrestrictedNetworkAccess adapter instead.

HttpPost

The adapter will report the body of a successful POST request to the specified post, or return an error if the response status code is greater than or equal to 400.

Parameters

  • post: takes a string containing the URL to make a POST request to.
  • headers: takes a object containing keys as strings and values as arrays of strings.
  • queryParams: takes a string or array of strings for the URL's query parameters.
  • extPath: takes a slash-delimited string or array of strings to be appended to the job's URL.
  • body: the JSON body (as a string) that will be used as the data in the request.

Solidity Example

req.add("post", "http://post.example.com");
req.add("queryParams", "firstKey=firstVal&secondKey=secondVal");
req.add("extPath", "price/BTC/USD");
req.add("body", "{\"myKey\":\"myVal\"}");

NOTE: For security, since the URL may come from an untrusted source, HTTPPost imposes some restrictions on which IPs may be fetched. Local network and multicast IPs are disallowed by default and attempting to connect will result in an error.

If you really must access one of these IPs, you can use the HTTPPostWithUnrestrictedNetworkAccess adapter instead.

JsonParse

The adapter walks the path specified and returns the value found at that result. If returning JSON data from the HttpGet or HttpPost adapters, you must use this adapter to parse the response.

Parameters

  • path: takes an array of strings, each string being the next key to parse out in the stringified JSON result or a single dot-delimited string.

Solidity Example

For the stringified JSON:

"{\"RAW\": {\"ETH\": {\"USD\": {\"LASTMARKET\": \"_someValue\"}}}}"

You would use the following for an array of strings:

string[] memory path = new string[](4);
path[0] = "RAW";
path[1] = "ETH";
path[2] = "USD";
path[3] = "LASTMARKET";
req.addStringArray("path", path);

Or the following for a single dot-delimited string:

req.add("path", "RAW.ETH.USD.LASTMARKET");

Job Specification Example

{
  "type": "JsonParse",
  "params": {
    "path": [
      "RAW",
      "ETH",
      "USD",
      "LASTMARKET"
    ]
  }
}

Multiply

The adapter parses the input into a float and then multiplies it by the times field.

Parameters

  • times: the number to multiply the input by.

Solidity Example

run.addInt("times", 100);

NoOp

The adapter performs no operations, simply passing the input on as output. Commonly used for testing.

Parameters

None taken.

NoOpPend

The adapter performs no operations, and marks its task run pending. Commonly used for testing.

Parameters

None taken.

Quotient

Quotient

The adapter gives the result of x / y where x is a specified value (dividend) and y is the input value (result).

This can be useful for inverting outputs, e.g. if your API only offers a USD/ETH conversion rate and you want ETH/USD instead you can use this adapter with a dividend of 1 to get the inverse (i.e. 1 / result).

Parameters

  • dividend: the number which is divided by the result

Sleep

The adapter will pause the current task pipeline for the given duration.

Parameters

  • until: the UNIX timestamp of when the job should stop sleeping and resume at the next task in the pipeline.

Solidity Example

req.addUint("until", now + 1 hours);

Updated 4 months ago

Adapters


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.