Oracle
Last updated
Last updated
A blockchain oracle is a service that connects blockchains to external data sources, allowing smart contracts to interact with real-world information. By providing data such as market prices, weather conditions, or sports scores, oracles enable blockchain applications to function beyond their isolated networks.
Theta Network currently lacks oracles, which are essential for connecting blockchains to real-world data. Integrating oracles can unlock numerous applications, such as decentralized finance (DeFi) services, gaming and more.
To incorporate data from external sources, we designed an architecture where four key actors interact seamlessly.
Initiates the process by calling the createRequest
function on the Oracle Smart Contract, specifying the required data.
Monitors the RequestFilled
event from the Oracle Smart Contract to receive the off-chain data.
Accepts the createRequest
call from the DogZilla Client and stores the request.
Emits a NewRequest
event to notify the DogZilla Node of the new request details.
Receives the updateRequest
call from the DogZilla Node and updates the request with the retrieved off-chain data.
Emits a RequestFilled
event to confirm the successful completion of the request and provide the requested data.
Listens for NewRequest
events from the Oracle Smart Contract and processes the request.
Queries the API Service using the data from the on-chain request.
Receives the JSON response from the API Service.
Calls the updateRequest
function on the Oracle Smart Contract with the received data.
An external off-chain service that supplies relevant data for application purposes.
Processes incoming queries.
Returns the requested data in JSON format.
To utilize our service, you can interact with our Oracle Smart Contract.
Each request sent to our Oracle Smart Contract incurs a service fee in DOGZ and a transaction fee in TFUEL:
Service Fee: 250 DOGZ
Transaction Fee: 0.5 TFUEL
In your client application (using Ether.js, Web3.js, WAGMI, etc.), make a call to the createRequest
function from our Oracle Smart Contract.
The required arguments may vary depending on the oracle type. For detailed information, please refer to Oracle Types.
Next, listen for the RequestFilled
event, parse the response, and utilize the off-chain data as needed.
If you want to perform a private request, set the priv
argument to true
. With this configuration, you will receive a different event called RequestFilledPriv
. This event confirms the request but does not provide the data directly, as it remains private and is accessible only to the address that generated the request. To retrieve the off-chain data generated by the request, call the readRequest
function.
To integrate our Oracle Smart Contract with your custom Smart Contract, simply use our contract interface and instance.
Contract -> 0xfb0996142e0324f93ad307c4cf14252746f395ad