Search
v1 Jobs are removed
The adapters or JSON adapters for v1 Jobs are removed for Chainlink nodes running version 1.0.0 and later. Use v2 job tasks instead.
See the v2 jobs migration page to learn how to migrate to v2 jobs.
Core adapters are the built-in functionality that every Chainlink node supports. Strung together, they act as tasks that need to be performed to complete a Job.
Adapters that are prefixed with "Eth" refer to tasks that post data onto the chain. Here are some examples of the data types that adapters convert data to.
Name | Core Adapter | Ethereum Data Type |
---|---|---|
Signed Integers | EthInt256 | int256 |
Unsigned Integers | EthUint256 | uint256 |
Bytes | EthBytes32 | bytes32 |
Boolean | EthBool | bool |
You can learn more about Solidity data types here.
This core adapter compares a user-specified value with the value from the previous adapter's result.
operator
: the operator used to compare values. You may use one of the following:eq
: Equalsneq
: Not equalsgt
: Greater thangte
: Greater than or equals tolt
: Less thanlte
: Less than or equals tovalue
: 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.req.addInt("value", 10000);
req.add("operator", "gte");
The core 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.
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.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 comma-delimited string:
req.add("copyPath", "RAW,ETH,USD,LASTMARKET");
Note: Chainlink nodes prior to
1.0.0
supported dot delimited strings instead of commas.
{
"type": "Copy",
"params": {
"copyPath": ["RAW", "ETH", "USD", "LASTMARKET"]
}
}
For arrays, you can access the path of an array by using the index. If this is your JSON:
{ "endpoint": [{ "path": "value" }] }
You could get the "value"
by:
req.add("copyPath", "endpoint.0.path");
The core adapter reads the given Boolean value and then converts it into Solidity's bool
format.
None taken.
The core adapter formats its input into a string and then converts it into Solidity's bytes32
format.
None taken.
The core adapter formats its input into an integer and then converts it into Solidity's int256
format.
None taken.
The core 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
.
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.The core adapter formats its input into an integer and then converts it into Solidity's uint256
format.
None taken.
The core 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.
get
: takes a string containing the URL to make a GET
request to.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.headers
: takes a object containing keys as strings and values as arrays of strings.Headers
Currently not available on-chain. Available for job specs only.
req.add("get", "http://example.com");
req.add("queryParams", "firstKey=firstVal&secondKey=secondVal");
req.add("extPath", "price/BTC/USD");
{
"type": "HttpGet",
"params": {
"get": "https://example.com/some-endpoint",
"headers": {
"X-API-Key": ["abc123abc123abc123abc123"]
}
}
}
For security, because the URL can 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.
The core 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.
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.Headers & Body
Currently not available on-chain. Available for job specs only.
req.add("post", "http://post.example.com");
req.add("queryParams", "firstKey=firstVal&secondKey=secondVal");
req.add("extPath", "price/BTC/USD");
{
"type": "HttpPost",
"params": {
"post": "https://example.com/some-endpoint",
"headers": {
"X-API-Key": [
"abc123abc123abc123abc123"
]
}
}
}
For security, because the URL can come from an untrusted source, HTTPPost imposes some restrictions on which IPs can 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.
The core 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.
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.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 comma-delimited string:
req.add("path", "RAW,ETH,USD,LASTMARKET");
Note: Chainlink nodes prior to 1.0.0 support dot-delimited strings instead of comma-delimited strings.
{
"type": "JsonParse",
"params": {
"path": ["RAW", "ETH", "USD", "LASTMARKET"]
}
}
req.add("path", "3,standardId");
The above example parses the 4th object of the following JSON response and returns 677 as a result:
[
{
standardId: 20,
name: 'ERC-20',
},
{
standardId: 721,
name: 'ERC-721',
},
{
standardId: 1155,
name: 'ERC-1155',
},
{
standardId: 677,
name: 'ERC-677',
},
];
The core adapter parses the input into a float and then multiplies it by the times
field.
times
: the number to multiply the input by.run.addInt("times", 100);
The core adapter performs no operations, simply passing the input on as output. Commonly used for testing.
None taken.
The core adapter performs no operations, and marks its task run pending. Commonly used for testing.
None taken.
Quotient
The core 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).
dividend
: the number which is divided by the resultThe core adapter will pause the current task pipeline for the given duration.
ENABLE_EXPERIMENTAL_ADAPTERS
You must set ENABLE_EXPERIMENTAL_ADAPTERS=true
in order to use the sleep adapter
until
: the UNIX timestamp of when the job should stop sleeping and resume at the next task in the pipeline.req.addUint("until", now + 1 hours);
{
"initiators": [
{
"type": "web",
"params": {
}
}
],
"tasks": [
{
"type": "sleep",
"params": {
"until": "1605651000"
}
}
]
}