Core Adapters
Core adapters are the built-in functionality that every Plugin 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.
Signed Integers
EthInt256
int256
Unsigned Integers
EthUint256
uint256
Bytes
EthBytes32
bytes32
Boolean
EthBool
bool
Compare
This core 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
: Equalneq
: Not equalgt
: Greater thangte
: Greater than or equal tolt
: Less thanlte
: Less than or equal 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, onlyeq
andneq
may be used.
Solidity Example
Copy
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.
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:
You would use the following for an array of strings:
Or the following for a single dot-delimited string:
Job Specification Example
For arrays, you can access the path of an array by using the index. If this is your JSON:
You could get the "value"
by:
EthBool
The core adapter reads the given Boolean value and then converts it into Solidity's bool
format.
Parameters
None taken.
EthBytes32
The core adapter formats its input into a string and then converts it into Solidity's bytes32
format.
Parameters
None taken.
EthInt256
The core adapter formats its input into an integer and then converts it into Solidity's int256
format.
Parameters
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
.
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 beforedataPrefix
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 thefunctionSelector
in the transaction's data field.value
: (optional) data to send to the function, will append after thedataPrefix
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.
Parameters
None taken.
HttpGet
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.
Parameters
get
: Takes a string containing the URL to make aGET
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 an object containing keys as strings and values as arrays of strings.
Solidity Example
Job Specification Example
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 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.
Parameters
post
: takes a string containing the URL to make aPOST
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
Job Specification Example
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.
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.
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:
You would use the following for an array of strings:
Or the following for a single dot-delimited string:
Job Specification Example
Parsing Arrays
The above example parses the 4th object of the following JSON response and returns 677 as a result:
Multiply
The core 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
NoOp
The core adapter performs no operations, simply passing the input on as output. Commonly used for testing.
Parameters
None taken.
NoOpPend
The core adapter performs no operations, and marks its task run pending. Commonly used for testing.
Parameters
None taken.
Quotient
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).
Parameters
dividend
: the number which is divided by the result
Sleep
The 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
Parameters
until
: the UNIX timestamp of when the job should stop sleeping and resume at the next task in the pipeline.
Solidity Example
Job Specification example
Last updated