🧙Oracle

What is an Oracle?

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.

Initiative

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.

Technical Specifications

To incorporate data from external sources, we designed an architecture where four key actors interact seamlessly.

On-Chain

DogZilla Client

  1. Initiates the process by calling the createRequest function on the Oracle Smart Contract, specifying the required data.

  2. Monitors the RequestFilled event from the Oracle Smart Contract to receive the off-chain data.

Oracle Smart Contract

  1. Accepts the createRequest call from the DogZilla Client and stores the request.

  2. Emits a NewRequest event to notify the DogZilla Node of the new request details.

  3. Receives the updateRequest call from the DogZilla Node and updates the request with the retrieved off-chain data.

  4. Emits a RequestFilled event to confirm the successful completion of the request and provide the requested data.

Off-Chain

DogZilla Node

  1. Listens for NewRequest events from the Oracle Smart Contract and processes the request.

  2. Queries the API Service using the data from the on-chain request.

  3. Receives the JSON response from the API Service.

  4. Calls the updateRequest function on the Oracle Smart Contract with the received data.

API Service

An external off-chain service that supplies relevant data for application purposes.

  1. Processes incoming queries.

  2. Returns the requested data in JSON format.

How can I use it?

To utilize our service, you can interact with our Oracle Smart Contract.

Pricing

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

Client Integration

In your client application (using Ether.js, Web3.js, WAGMI, etc.), make a call to the createRequest function from our Oracle Smart Contract.

function createRequest (string memory oracleType, uint256 [] memory args, bool priv) 

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.

Private Request

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.

 function readRequest (uint256 id) external view returns (uint256)

Solidity Integration

To integrate our Oracle Smart Contract with your custom Smart Contract, simply use our contract interface and instance.

Contract -> 0xfb0996142e0324f93ad307c4cf14252746f395ad

interface IDogOracle {
    ...
}

contract CustomContract {
    IDogOracle public oracle;
    
    constructor() {
        oracle = IDogOracle(0xfb0996142e0324f93ad307c4cf14252746f395ad);
    }
}

Oracle Types

đŸ”ĸRandom Number

Last updated