Oracle Sources Description

When making a request to the GoraNetwork, an application must specify a sourceId to fetch the data from. In addition, it must also specify the arguments that sourceId requires, the valuePath to extract the required value from, and the valueType which defines the type of the return value. To summarize, the following three arguments required to encode a request spec are obtained from the Oracle Sources List.

  • sourceArg: byte[] - an argument for a parameterized Oracle source

  • sourceArgList: SourceArg[] - a list of the above

  • sourceId: uint32 - numeric ID of an oracle source

Example

Let's say you would like to get the current spot price of Bitcoin. After looking through the Oracle Source list, you find the endpoint that will get you what you need.

ID: 7
Name: goraPriceFeedsWithParams
Description: Price feeds with param definitions and aggregated by GoraNetwork
Type: json
Value type: number
Round to digits: ##3
URL: https://price-feeds.gora.io/api/v2/crypto/prices?key=##0&assets=##1&curr=##2
Timestamp path: $.timestamp
Value path: $.price
Arguments:
#0: string (required) - API endpoint access key
#1: string (required) - Asset or comma separated assets codes to get prices for
#2: string (required) - Currency or comma seperated currencies codes to get prices for
#3: number (default: 8) - Number of significant digits to round result to

With the above source definition, you can construct a sourceArgList for Bitcoin as follows

sourceId = 7;

sourceArg0 = Buffer.From(api_key);
sourceArg1 = Buffer.From('btc');
sourceArg2 = Buffer.From('usd');
sourceArg3 = 2;

sourceArgList = [
   sourceArg0,
   sourceArg1,
   sourceArg2,
   sourceArg3
]

The above example uses a source that predefines the valueType and the valuePath. In the example below, an Oracle Source List that request a defined valueType and valuePath is shown.

ID: 10
Name: goraWeatherFeeds
Description: Weather feeds aggregated by GoraNetwork
Type: json
Value type: ##3
URL: https://weather-feeds.gora.io/api/v1/##0?key=##1&##2
Timestamp path: $.timestamp
Value path: ##4
Arguments:
#0: string (required) - URL endpoint to query
#1: string (required) - API endpoint access key
#2: string (required) - URL request params
#3: string (required) - Return value type
#4: string (required) - JSONPath expression to extract source value

This source gets a weather feed. However, rather than a predefined value (i.e price, as in the previous example), a user may define which value they would like, such as temperature, windspeed, feelsLike or any other value in the JSON response.

Note: you will notice the above source requires a value for endpoint. Endpoints can be found on the GoraNetwork App under the relevant feed. The urlParams format may also be found there.

// Some codeID: 6
sourceId = 6;

sourceArg0 = Buffer.From(endpoint);
sourceArg1 = Buffer.From(api_key);
sourceArg2 = Buffer.From("country=canada&area=toronto");
sourceArg3 = Buffer.From('number')
sourceArg4 = Buffer.From('$.temperature');

sourceArgList = [
   sourceArg0,
   sourceArg1,
   sourceArg2,
   sourceArg3,
   sourceArg4
]

Last updated