Skip to main content
LayerZero Read currently supports a variety of data types for reading external state via calldata from EVMCallRequestV1. The following types of calldata methods are supported:
  1. Public State Variables: Direct access to public state variables on target contracts.
  2. View or Pure Functions: Functions that do not modify the blockchain state and only return data.
  3. Non-View or Pure Functions Returning Data: Functions that are not marked as view or pure, but do not alter the onchain state and only return data.
These supported data types enable developers to fetch and utilize external state data efficiently without incurring unnecessary gas costs or affecting the target blockchain’s state.

Function Types

See the simple data type examples below for reference on how to implement EVMCallRequestV1 in your OAppRead application.

State Variables

Public state variables in Solidity automatically generate getter functions, making them easily accessible for read operations. LayerZero Read can directly interact with these getter functions to retrieve the current state:
To read the data variable using lzRead, you can encode the getter function call as follows:

View or Pure Functions

view and pure functions are ideal for read operations as they do not modify the blockchain state. LayerZero Read can seamlessly interact with these functions to retrieve necessary data.
To read the result of the add function using lzRead:

Non-View or Pure Functions Returning Data

Some functions are not marked as view or pure, but still do not modify the onchain state. These functions can also be utilized with lzRead as long as they only return data without performing state changes. For example, Uniswap V3’s IQuoterV2 relies on calling non-view functions and reverting to compute the result. This is not gas efficient and should not be called onchain, making lzRead a great option for retrieving the state:
To read a quote for an amountOut for a specific token pair function using lzRead: