Religant is a decentralized oracle service designed to provide accurate and up-to-date price data feeds on the Radix network.
Functionality
The Religant Oracle protocol operates by aggregating data from various sources. A network of data nodes queries exchanges for current transaction data and submits this information to a contract. This contract employs a consensus mechanism to determine the aggregate price. Data nodes, running the Religant node backend software, update the feed at regular intervals or when the new aggregate price exceeds a specified divergence threshold, currently set at 2%. This threshold ensures that the rate from the Religant oracle's feed remains within 2% of actual transaction rates on exchanges.
Component API
The user-facing API of the Religant Oracle is straightforward, consisting of a single method, get_price
, which returns a PriceData
structure containing the current XRD/USD exchange rate and a timestamp. The Option
wrapper in the return type ensures type safety, with the method usually returning a valid result after the initial round of Oracle feed aggregation.
Integration Guide
Integrating the Religant Oracle into an application requires several steps:
- Defining the
PriceData
structure outside of the application blueprint, using various traits and types likeScryptoSbor
,USDValue
, andPOSIXTime
. - Declaring the component's API within the blueprint module using an
extern_blueprint!
macro. - Instantiating a reference to the global Religant component within the blueprint.
- Using the Religant component's methods within the application, such as retrieving the current exchange rate and minting tokens based on this rate.