How It Works
Request Creation
A request is made from the source chain for an asset symbol whose price is required (e.g. ETH/USD) which then passes through the chain’s mailbox to be then delivered to the destination chain. You check the available contract address on testnet based on the destination chain you’re reading from here. The request body is formatted as follows in JavaScript:Message Delivery Process
Once a request is created, it is transmitted to the Hyperlane mailbox. The message is then relayed to theOracleRequestRecipient 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.Making a Price Request
In this example, we’ll be sending an ETH/USD price request from Base Sepolia to DIA Lasernet. Start by cloning theSpectra Interoperability repository to your local machine and switching to the deploybranch:
GitHub - diadata-org/Spectra-interoperability
cd contracts folder, and export your wallet’s private key in your terminal as follows:
sendMessage.mjs script will trigger a request transaction to fetch the latest price of ETH/USD from DIA lasernet. To run the script:
--network flag (e.g. --network sepolia).
Once the price update takes place on the destination chain, which you can track from the hyperlane explorer, you can check the txn logs for the ReceivedMessageevent on the pull oracle contract or call the updatesfunction.
