Plugin,a Decentralized Oracle built on XDC Network
  • Migrating from Plugin Node V2 to V2.4 Without Changing the Node Address
    • 1 - Backup on Plugin Node V2.0
    • 2 - Installation and Configuration of Plugin Node V2.4
    • 3 - Importing PluginV2 Node Address into PluginV2.4
    • 4. Backup After Plugin V2.4 Upgrade
  • Plugin 2.0 - Node Operators
    • Introduction
    • Unstake PLI Tokens from Plugin 1.0 Node
    • Plugin 2.0 Set Up Requirements
    • Node Installation
      • Node Fulfillment
      • Job Setup
        • Steps to Setup Direct Request Job
      • Process of Approval
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • PLUGIN 2.0 - Validators
    • Introduction
    • Set-up Requirements
    • Job Setup
      • Steps to Setup Direct Request Job
      • Flux Monitor Job
        • Idle Timer
        • Drum Beat
        • Poll Timer
        • POLL TIMER + IDLE TIMER (Recommended)
      • Process Of Approval
      • Rewards Information
    • OCR Set-up
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • WALLET
    • XDCPay - Apothem
    • XDCPay - Mainnet
  • PLUGIN VRF SUBSCRIPTION
    • Introduction
    • Guidance on Utilizing Random Values
    • Creation and Deployment of VRF-Consumer Contract
    • Requesting Random Values
  • Multichain
    • PLISwap - How to instructions
  • Plugin Data Feeds platform
    • Introduction
    • End data consumers - Mainnet
    • End data consumers - Apothem
    • Benefits
  • Restaking Model
    • Introduction
      • Scenarios in Re-staking Model
      • Benefits To Node Members
      • Steps for Restaking
  • Tips and tricks
    • Known-Issues
    • Open-Issues
  • Plugin 1.0 Installations - Deprecated
    • How to install Plugin 1.0 Node
      • Modular Method Deployment (Recommended Approach)
      • Script Method (Legacy)
        • Script - Phase 1
        • Script - Phase 2
      • Docker Method
        • Docker - Phase 1
        • Docker - Phase 2
    • Core Adapters
    • Fund your Node
  • External Initiators - Deprecated
    • Introduction
    • Installation
    • Setup & Build
  • Oracle Plugin 1.0 - Deprecated
    • Deployment
    • Fulfillment Request
    • Job-Setup
    • Testing
  • Job-Tasks Plugin 1.0 Deprecated
    • Sleep
    • Get > Bytes32
    • HttpGet
    • CRON
    • Web
  • External Adapters Plugin 1.0 - Deprecated
    • Introduction
    • Implement External -Adapters
    • Define Bridge
    • Add Bridge to Job Spec
  • Deprecated
    • How to use
  • Use Cases
    • Plugin WFN Use Case
      • Plugin WFN Data Review
      • Plugin WFN Use Case - FAQ
      • Plugin WFN - Ambient Weather Unit Onboarding Instructions
      • Plugin WFN - Acurite Weather Unit Onboarding Instructions - LEGACY
      • Unlock WFN Node
    • Crypto Compare - Pricing Index
  • Node Operators
    • How to Register / Sign-up
    • How to enable 2FA
    • How to update profile
    • How to add XDC Wallet Address
    • How to Navigate Dashboards
    • How to submit Node Details
    • How to stake PLI token for Plugin Node
    • How to add Job to your node
    • View the node details
    • De-Activate / Re-activate my nodes
    • Withdraw staked PLI
    • Withdraw PLI from Plugin Node
    • Withdraw PLI from Oracle contract
    • How to add more stake in Node?
    • How to Migrate my Plugin Node to New Server?
    • How to Un-Stake the node.
    • How a Reputation is calculated?
    • Node Maintenance Instructions for node operators
  • FEATURES
    • PLI Yield Farming
      • Steps for Staking in Plugin Yield Farming (PLIYF)
      • PLIYF - FAQ
  • Support
    • FAQ
  • RESOURCES
    • Node Setup Video Tutorials
    • Community Supports
    • How to Submit your node details - Video Tutorial
  • CHANGELOG
    • v1.0.1
    • V1.0.2
    • V1.0.3
    • V1.0.4
    • V1.05
  • Terms and Conditions
Powered by GitBook
On this page
  • Compare
  • Copy
  • EthBool
  • EthBytes32
  • EthInt256
  • EthTx
  • EthUint256
  • HttpGet
  • HttpPost
  • JsonParse
  • Multiply
  • NoOp
  • NoOpPend
  • Quotient
  • Sleep
  1. Plugin 1.0 Installations - Deprecated

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.

Name
Core Adapter
Ethereum Data Type

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: Equal

    • neq: Not equal

    • gt: Greater than

    • gte: Greater than or equal to

    • lt: Less than

    • lte: 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, only eq and neq may be used.

Solidity Example

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

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:

{"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"
    ]
  }
}

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");

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

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 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 an object containing keys as strings and values as arrays of strings.

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"
      ]
    }
  }
}

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 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");

Job Specification Example

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

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:

{"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"
    ]
  }
}

Parsing Arrays

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"
    }
]

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

run.addInt("times", 100);

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

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

Job Specification example

{
  "initiators": [
    {
      "type": "web",
      "params": {
      }
    }
  ],
  "tasks": [
    {
      "type": "sleep",
      "params": {
        "until": "1605651000"
      }
    }
  ]
}
PreviousDocker - Phase 2NextFund your Node

Last updated 2 years ago

EthTx

EthUint256

JsonParse

Link to this section
Link to this section
Link to this section