Pull based oracles

Pull Based Oracle

Pull or also known as Request Based Oracle enables the creation of requests for asset prices on a source blockchain. These requests are sent through a mailbox on the current chain and ultimately delivered to the DIA chain, which retrieves and delivers the required price data.

How It Works

1. Request Creation

A request can be made from the source chain for an asset symbol whose price is required. These requests pass through the chain's mailbox, and the respective mailbox addresses are as follows:

MailBox

Reciepient

ISM Address

2. Request Body Format

The request body is formatted as follows in JavaScript:

const key =  "WBTC/USD"; // Assuming key is an address or a bytes32 value

const requestBody = abiCoder.encode(
    ["string"],  // Types of the parameters
    [key]        // Values to encode
);

The request body is formatted as follows in solidity:

    bytes memory requestBody = abi.encode("WBTC/USD");

Message Delivery Process

Once a request is created, it is transmitted to the Hyperlane mailbox. The message is then relayed to the OracleRequestRecipient contract , where the price data is fetched from the Oracle Metadata Contract.

Response and Callback

Upon receiving the request, the DIA chain initiates a transaction to deliver the message back to the end contract on the source chain. The recipient contract on the source chain must implement the IMessageRecipient interface, which includes a handle function that will receive the price quotation.

Recipient

Example Request Based Oracle

Pull Base Oracle Flow

Last updated