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.
Constructor Parameters:
Request Methods:
Method Name | Method Params | Response |
---|---|---|
addSource | source | RADRequest |
setAggregator | aggregator | RADRequest |
setTally | tally | RADRequest |
setQuorum | witnesses ,min_consensus_percentage | RADRequest |
setCollateral | collateral | RADRequest |
setFees | reward ,commit_and_reveal_fee | RADRequest |
schedule | timestamp | RADRequest |
setTimestamp | timestamp | RADRequest |
asJson | none | Map |
The addSource
method pushes a source to the retrieve
array and sets the data point type to the last type of the source.
The setAggregator
method sets a aggregate field
(RADAggregate
) for data aggregation.
Method to set the tally for data aggregation.
rejects unsupported operators
sanitize malformed filters and reject unsupported filters
Method to set the quorum parameters
witnesses
: the number of witnessesmin_consensus_percentage
: the minimum consensus percentage
collateral
: the collateral amount in nanoWIT which needs to be >= 1 WIT e.g. 1000000000 nanoWIT
reward
: the witness rewardcommit_and_reveal_fee
: the commit and reveal fee
- timestamp
timestamp
kind
: The enum value representing the RADKind.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.
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 RequestRNG
: 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. |
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,
})
Constructor Parameters:
op
: The op parameter refers to a RADONFilter OP Code, the available codes are listed below.args
:
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,
})
Discards any result that is more than the provided input times the standard deviations times away from the average.
OP Code: 0x05
Discards any result that is the different from the mode.
OP Code: 0x08
Computes the mode of the values.
OP Code: 0x02
Computes the average mean.
OP Code: 0x03
Computes the average median.
OP Code: 0x05
Computes the standard deviation.
OP Code: 0x07
Computes the hash and concatenates the values.
OP Code: 0x0B