lzRead), LayerZero offers CLI examples that streamline the setup and configuration process, similar to the standard CLI examples provided for other LayerZero functionalities.
Using the Read CLI
To begin usinglzRead, follow the steps below. These instructions utilize the same commands as the standard setup for OApps but include minor adjustments specific to configuring read capabilities.
Create Your lzRead Repo
Run the following command to create a new LayerZero OApp with read capabilities enabled:hardhat.config.ts, adding your MNEMONIC or PRIVATE_KEY to .env, etc.)
npx hardhat:
lzRead CLI methods have been modified from the base CLI, so all lz:oapp: and lz:oapp:read methods should behave similarly.
Configure LayerZero Config
Unlike standard OApp configurations,lzRead requires specific settings in the layerzero.config.ts file. Instead of configuring connections, you’ll focus solely on defining contracts and read channels:
hardhat.config.ts by running:
layerzero.config.ts file based on the READ_CONTRACT_NAME and available networks in your hardhat project.
Key configuration details include:
-
contracts: Define the contracts you intend to interact with. In this example, the origin chain Arbitrum has the childOAppReadcontract address. -
readLibrary: The address of the Read Library (ReadLib1002) contract deployed on your network. -
readChannels: Specify the read channels you want to activate. -
readConfig: Configure the Read Library settings, including required Decentralized Verifier Networks (DVNs) and the executor address.
Wire Your Read OApp
After configuringlayerzero.config.ts, execute the following command to wire your Read OApp:
layerzero.config.ts file, enabling your OApp to perform read operations.
Debugging Malformed or Unresolvable Commands
LayerZero provides a Hardhat task to assist in debugging and resolving read commands. This task helps identify and troubleshoot issues with your read commands. To resolve a read command, run the following command in your terminal:Testing Contracts
Ensuring the reliability of yourlzRead setup involves thorough testing. LayerZero provides a TestHelper tailored for Foundry unit tests, enabling you to simulate crosschain reads in your tests.
For lzRead, this helper has been extended to support read-specific functionalities. Some limitations of this testing method should be understood:
- Command Validation: Does not simulate whether a command is
malformedorunresolvable.