LogoLogo
WebsiteDiscordTelegramTwitter
  • 🏠Witnet Oracle Docs
  • Introduction
    • ❓What is Witnet?
      • ⚙️Oracle Architecture
      • 🪙The Witnet Coin (Wit)
      • 👛Wallets
      • 🤔Frequently Asked Questions
      • 😎Awesome Witnet
    • 🚀Quick Tutorials
      • 📈Price Feeds
      • 🎲Randomness
      • 🌐APIs and HTTP GET/POST
      • ⛏️Mining Wit
  • Smart contracts developers
    • ⛓️Supported chains
    • 🔮Wit/Oracle
      • HTTP GET Requests in Solidity
      • HTTP POST Requests in Solidity
      • Query GraphQL APIs in Solidity
      • Dynamic Requests in Solidity
      • UsingWitnet Inheritance
      • API Reference
        • Solidity API
          • Solidity Contracts
            • WitnetRequestBoard
        • Javascript API
        • RADON API
          • RADON Type System
          • RADON Errors
      • Multi-chain Addresses
    • 💹Wit/Price Feeds
      • How To Use Witnet Price Feeds
      • Update Conditions
      • Code Examples
      • API Reference
      • Multi-chain Addresses
        • Arbitrum Price Feeds
        • Avalanche Price Feeds
        • Base Price Feeds
        • Boba Price Feeds
        • Celo Price Feeds
        • Conflux Price Feeds
        • Cronos Price Feeds
        • Dogechain Price Feeds
        • Elastos Price Feeds
        • Ethereum Price Feeds
        • Gnosis Chain Price Feeds
        • Kaia Price Feeds
        • Kava Price Feeds
        • KCC Price Feeds
        • Mantle Price Feeds
        • Meter Price Feeds
        • Metis Price Feeds
        • Moonbeam Price Feeds
        • OKX Price Feeds
        • Optimism Price Feeds
        • Polygon Price Feeds
        • Reef Price Feeds
        • Scroll Price Feeds
        • Syscoin Price Feeds
        • Ultron Price Feeds
        • Request new price feed or chain support
    • 🎲Wit/Randomness
      • Generating Randomness
      • WitnetRandomness Contract
      • Low-level Requests
      • Code Examples
      • API Reference
      • Multi-chain Addresses
    • 🏗️Guides
      • 📖Solidity Contracts
        • Appliances
          • 📃WitnetPriceFeeds
          • 📃WitnetRandomness
        • Core
          • 📃WitnetOracle
          • 📃WitnetRadonRegistry
          • 📃WitnetRequest
          • 📃WitnetRequestFactory
          • 📃WitnetRequestTemplate
        • Mockups
          • 📃UsingWitnet
          • 📃UsingWitnetRandomness
          • 📃UsingWitnetRequest
          • 📃UsingWitnetRequestTemplate
          • 📃WitnetRandomnessRequestConsumer
          • 📃WitnetRequestConsumer
          • 📃WitnetRequestTemplateConsumer
      • 🧙Solidity Wizard
    • 🎓Tutorials
      • Building a Satoshi/Wei custom price feed
  • Witnet Node Operators
    • 🖥️Requirements
    • 🚀Witnet Node Quick Start Guide (Docker)
    • 🔎Next steps
    • 📄CLI Reference
    • 🤓Advanced Setups
      • Run Witnet as a systemd service
      • Run Witnet as a docker compose service
      • Paranoid mode (Witnet over proxies and Tor)
      • Configuration file
  • Witnet Node Developers
    • 🏗️Integration Guide
      • Node API Reference
      • Wallet API Reference
    • 🗜️Compile witnet-rust from Source Code
Powered by GitBook
On this page
  • RADRequest
  • addSource
  • setAggregator
  • setTally
  • setQuorum
  • setCollateral
  • setFees
  • schedule
  • setTimestamp
  • asJson
  • RADRetrieve
  • RADKind
  • RADTally
  • RADFilter
  • RADAggregate
  • RAD Filters
  • RAD Reducers
  • mode
  • averageMean
  • averageMedian
  • deviationStandard
  • hashConcatenate

Was this helpful?

Edit on GitHub
  1. Smart contracts developers
  2. Wit/Oracle
  3. API Reference

RADON API

PreviousJavascript APINextRADON Type System

Last updated 1 year ago

Was this helpful?

RADON is a scripting language that retrieves, attests to, and delivers data within the Witnet Decentralized Oracle Network, facilitating the conversion of the request into a CBOR representation and subsequently into a protobuf bytes schema.

There are several components that are used to build a RADON Request.

RADRequest

Constructor Parameters:

Request Methods:

Method Name
Method Params
Response

source

RADRequest

aggregator

RADRequest

tally

RADRequest

witnesses, min_consensus_percentage

RADRequest

collateral

RADRequest

reward, commit_and_reveal_fee

RADRequest

timestamp

RADRequest

timestamp

RADRequest

none

Map

addSource

The addSource method pushes a source to the retrieve array and sets the data point type to the last type of the source.

setAggregator

setTally

Method to set the tally for data aggregation.

rejects unsupported operators

sanitize malformed filters and reject unsupported filters

setQuorum

Method to set the quorum parameters

  • witnesses: the number of witnesses

  • min_consensus_percentage: the minimum consensus percentage

setCollateral

  • collateral: the collateral amount in nanoWIT which needs to be >= 1 WIT e.g. 1000000000 nanoWIT

setFees

  • reward: the witness reward

  • commit_and_reveal_fee: the commit and reveal fee

schedule

  • timestamp

setTimestamp

timestamp

asJson

RADRetrieve

  • script: the RADON script that specifies the retrieval from the source data.

  • url: The URL of the retrieval.

  • body: The body is an optional field used for the HTTP request.

  • headers: The headers are an optional field used for the HTTP request.

RADKind

Each RADRetrieve object is associated with a RADKind, represented by an enum with values ranging from 0 to 3. The possible enum values are "Unknown," "HTTP-GET," "RNG," and "HTTP-POST."

  • Unknown: An unknown RAD Request type.

  • HTTP-GET: A HTTP GET Request

  • RNG: A request to generate a secure random number.

  • HTTP-POST: A request to generate a secure random number.

// Retrieve data from a HTTP-GET Source
const httpGetSource = new Witnet.Source("https://...")
// Retrieve a secure random number
const randomSource = new Witnet.RandomSource()
//Retrieve data from a HTTP-POST Source
const httpPostSource = new Witnet.Source("https://...",
  ``
)
// Retrieve data from a GraphQL Source
const graphQLSource = new Witnet.GraphQLSource("https://api.thegraph.com/subgraphs/name/beamswap/beamswap-dex"
 `{
    pair(id:\"0x61b4cec9925b1397b64dece8f898047eed0f7a07\")
      { 
        token0Price 
      } 
  }`
)
OP Code
Name
Description

0x00

Unknown

An unknown RAD Request type.

0x01

HTTP-GET

A HTTP GET Request

0x02

RNG

A request to generate a secure random number.

0x03

HTTP-POST

A request to generate a secure random number.

RADTally

  • filters: An array of RADFilters.

  • reducer: A Single RADReducer.

A RADTally has an array of of type RADFilter and a single RadonReducer.

// Filters out any value that is more than 2.5 times the standard
// deviationaway from the average, then computes the average mean of the
// values that pass the filter.
const tally = new Witnet.Tally({
  filters: [
    [Witnet.Types.FILTERS.deviationStandard, 2.5],
  ],
  reducer: Witnet.Types.REDUCERS.averageMean,
})

RADFilter

Constructor Parameters:

  • op: The op parameter refers to a RADONFilter OP Code, the available codes are listed below.

  • args:

RADAggregate

  • RADFilter:

  • RadonReducer:

A RADAggregate has an array of type RADFilter and a single RadonReducer.

// Filters out any value that is more than 1.4 times the standard
// deviationaway from the average, then computes the average mean of the
// values that pass the filter.
const aggregator = new Witnet.Aggregator({
  filters: [
    [Witnet.Types.FILTERS.deviationStandard, 1.4],
  ],
  reducer: Witnet.Types.REDUCERS.averageMean,
})

RAD Filters

deviationStandard

Discards any result that is more than the provided input times the standard deviations times away from the average.

OP Code: 0x05

mode

Discards any result that is the different from the mode.

OP Code: 0x08

RAD Reducers

mode

Computes the mode of the values.

OP Code: 0x02

averageMean

Computes the average mean.

OP Code: 0x03

averageMedian

Computes the average median.

OP Code: 0x05

deviationStandard

Computes the standard deviation.

OP Code: 0x07

hashConcatenate

Computes the hash and concatenates the values.

OP Code: 0x0B

The setAggregator method sets a aggregate field () for data aggregation.

kind: The enum value representing the .

🔮
RADRequest
RADFilter
RADRetrieve
RADKind
RADTally
RADFilter
RADAggregate
Filters
Reducers
retrieve
aggregate
tally
RADAggregate
RADKind
addSource
setAggregator
setTally
setQuorum
setCollateral
setFees
schedule
setTimestamp
asJson