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.

arrow-up-rightHow Cross-Chain Reads Work

  1. A contract on one chain requests data from multiple chains.

  2. The CCIP Read ISM validates the read request and forwards it to Hyperlane’s message relayers.

  3. Hyperlane retrieves data from off-chain RPC nodes, aggregates it, and relays it back.

  4. The data is returned to the contract that initiated the read.

arrow-up-rightProtocol Interface

CopyAsk AI

interface IMetaLayerRead {
    function fetchCrossChainData(
        uint32[] calldata sourceChains,
        address user,
        bytes calldata queryData
    ) external view returns (bytes[] memory);
}

arrow-up-rightExplanation of ReadOperation Struct

Each cross-chain read operation is encapsulated in a ReadOperation struct:CopyAsk AI

  • 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.

arrow-up-rightExample: Querying Data from 4 Chains

This example demonstrates how a contract queries balances from multiple chains.

arrow-up-rightCross-Chain Data Reader

CopyAsk AI

Last updated