Cross-Chain Reads
Why Use Cross-Chain Reads?
Many decentralized applications rely on data from multiple chains. Some key use cases include:
- Aggregating liquidity across chains for better DeFi execution.
- Fetching token ownership or balances across chains before execution.
- Governance protocols checking votes on multiple chains before passing a decision.
How Cross-Chain Reads Work
- A contract on one chain requests data from multiple chains.
- The CCIP Read ISM validates the read request and forwards it to Hyperlane’s message relayers.
- Hyperlane retrieves data from off-chain RPC nodes, aggregates it, and relays it back.
- The data is returned to the contract that initiated the read.
Protocol Interface
Explanation of ReadOperation Struct
Each cross-chain read operation is encapsulated in a ReadOperation
struct:
sourceChain
: The ID of the chain where data is being queried.contractAddress
: Address of the contract being queried.callData
: Encoded function call to retrieve data.
Example: Querying Data from 4 Chains
This example demonstrates how a contract queries balances from multiple chains.