Skip to content

Adapters

Alex Kwiatkowski edited this page Jan 14, 2020 · 12 revisions

NOTE: Due to the nature of our development cycle, this page may be out of date. Please see our official Adapters documentation for up the most up to date documentation.

Bridge

The adapter is in charge of speaking with External Adapters.

Parameters

  • url: takes a string containing the location of the external adapter. Bridge can create pending task runs, and resume them via PUT requests to /runs/:RUN_ID.

Copy

The adapter walks the copyPath specified and returns the value found at that result.

Parameters

  • copyPath: takes an array of strings, each string being the next key to parse out in the JSON object.

Solidity Example

For the JSON object:

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

You would use:

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

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 TX_MIN_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.

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 url, or return an error if the response status code is greater than or equal to 400.

Parameters

  • url: takes a string containing the URL to make a GET request to.

Solidity Example

run.add("url", "http://example.com");

HttpPost

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

Parameters

  • url: takes a string containing the URL to make a POST request to.

Solidity Example

run.add("url", "http://post.example.com");

JsonParse

The adapter walks the path specified and returns the value found at that result.

Parameters

  • path: takes an array of strings, each string being the next key to parse out in the JSON object.

Solidity Example

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

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.

Sleep

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

Parameters

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

Solidity Example

run.addUint("until", now + 1 hours);
Clone this wiki locally