hardhat.config.ts and layerzero.config.ts files starting from the Current Working Directory. This file normally lives in the root of your project.
This guide shows how to add a new EVM network to your existing LayerZero project.
Example scenario: You have an OFT deployed on Optimism Sepolia and Base Sepolia, and want to add Arbitrum Sepolia to your mesh.
Existing networks in your mesh:
- Optimism Sepolia (EID: 40232)
- Base Sepolia (EID: 40245)
- Arbitrum Sepolia (EID: 40231)
- Update
hardhat.config.tswith the new network’s LayerZero Endpoint ID (EID) and RPC - Deploy your contract to the new network
- Update
layerzero.config.tsto declare the contract and connections - Wire peers and apply configuration across pathways
Update dependencies
Ensure you have the latest versions of @layerzerolabs/lz-evm-sdk-v2 and @layerzerolabs/lz-definitions. Update or install the packages using your preferred package manager:@layerzerolabs/lz-definitions may result in an error such as TypeError: Cannot read properties of undefined (reading 'toString').
Using an outdated version @layerzerolabs/lz-evm-sdk-v2 may result in the error Error: No deployment found for: EndpointV2.
Add the network to hardhat.config.ts
Add an entry with the LayerZero Endpoint ID, RPC URL, and your deployer accounts. Here’s the diff showing what to add:
The only notable change from a standard
hardhat.config.ts setup is the inclusion of a LayerZero Endpoint ID.For hardhat specific questions, refer to the Hardhat Configuration documentation.Deploy your contract to the new network
Use the CLI to deploy your contract to the added network. You can deploy interactively or target a specific network.Add the new contract and connections to layerzero.config.ts
Specify which contracts should be connected on a per pathway basis and set the security stack values:
Wire peers and apply configuration
Set peers, libraries, DVN/Executor settings, and enforced options per yourlayerzero.config.ts.
When delegate and owner are your local EOA (not recommended):
--output-filenamewill generate a JSON file with the list of transactions rather than submitting the transactions for execution directly- When asked to preview txns, you can choose
Yor just terminate the process immediately, as at this point, the JSON file would have already been generated. If asked “Would you like to submit the required transactions?”, respond withNto terminate the process. - View the generated JSON at
wiring-txns.jsonto view the txns data that need execution - Import them into your Multisig for execution
Verify connections and configuration
Checking Pathway Configurations
To check your OApp’s current configuration, you can run:-
Custom OApp Config: your
layerzero.config.tsconfiguration changes, with null values for unchanged parameters. - Default OApp Config: the default LayerZero configuration for the pathway.
- Active OApp Config: the combination of your customized and default parameters, i.e., the active configuration.