calldata from EVMCallRequestV1. The following types of calldata methods are supported:
-
Public State Variables: Direct access to
publicstate variables on target contracts. - View or Pure Functions: Functions that do not modify the blockchain state and only return data.
-
Non-View or Pure Functions Returning Data: Functions that are not marked as
vieworpure, but do not alter the onchain state and only return data.
Function Types
See the simple data type examples below for reference on how to implementEVMCallRequestV1 in your OAppRead application.
State Variables
Public state variables in Solidity automatically generategetter functions, making them easily accessible for read operations. LayerZero Read can directly interact with these getter functions to retrieve the current state:
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.
add function using lzRead:
Non-View or Pure Functions Returning Data
Some functions are not marked asview 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:
amountOut for a specific token pair function using lzRead: