Deploy Omnichain Implementation
This step-by-step guide will outline the necessary procedures for deploying the LayerZero ODCs.
You need to have some familiarity with the following prerequisites:
Prerequisite | Link |
---|---|
Solidity | https://docs.soliditylang.org/en/latest/ |
yarn | https://yarnpkg.com/getting-started |
TypeScript | https://www.typescriptlang.org/ |
hardhat | https://hardhat.org/ |
ethers.js | https://docs.ethers.io/v5/ |
Foundry | https://book.getfoundry.sh |
Preparation Steps
1. Add environments variables
Create a GITHUB_TOKEN on your official GitHub account under Developer Settings
> Personal Access Tokens
> Tokens (classic)
. Generate a token with all permissions except for deleting repositories.
Add it as an environment variable on your local machine:
2. Install dependencies
Install dependencies required for the deployment:
3. Build contracts
Begin building the contracts by running the following command:
4. Tests
To run the tests, execute the following command:
Note
Ensure that a .npmrc file is present in your root directory.
Note
Ensure that a .yarnrc.yaml file is present in your root directory.
If you wish to run linting or check the contract sizes run these commands:
Deploying contracts
Note that the Salt definition in deterministic deploy scripts is hardcoded and not tied to any specific version. This technical debt will be addressed soon. The functionality works as expected, but it is not parameterized.
Basic omnichain setup
This first step is required for a full deployment or if ERC-7208 is being used for the first time on a network. The main reusable components of the Nexera Standard are the Data Index, DataPoint Registry, and OmnichainProxy.
For each chain:
For correct LayerZero configuration, it is important to copy the deployed Omnichain Proxy address and paste it into the configuration file at shared/constants.ts
. Please fill in the OmnichainProxy
address, along with the chainId
and eid
if necessary.
Next, we will run the LayerZero OApp configuration command between our two OmnichainProxies. During the interactive process presented in the terminal, select only the networks you intend to support.
To complete the proxy configuration, let's run the ODC-specific Omnichain configuration.
For chain 1:
For chain 2, we need to run the same command, but with the network names switched:
Omnichain tokens
To create a proper Omnichain Token following the ERC-7208 design pattern, you will need to deploy the core contracts and omnichain support contracts on the desired number of chains.
ERC20 Omnichain Deployment
The following commands are specific to the use case and will deploy a custom ERC example:
In chain 2:
Approves a local DataManager for a remote DataPoint (on chain 1):
If registering the increase balancer fails, re-run the process with the following command:
Provided Data Object implementations
It is also possible to reuse DataObject deployments on each network. Remember, the DataObject manages the logic for handling storage associated with the DataPoint. Since modifications to DataPoint storage are only allowed at the discretion of the DataPoint deployer, we can reuse the DataObject logic and omnichain configuration if desired. This can help reduce the deployment fees required for a token under ERC-7208.
Omnichain Fungible Token With LocalMintBurnSupply Data Object
To deploy a Vault Data Object for the first time, run the following command:
Configure the default data index implementation and omnichain functionalities. On chain 1, we will first set it up to accept calls from the destination chain.
In chain 2:
Vault Data Object
To deploy a Vault Data Object for the first time, run the following command:
This will also configure the default data index implementation. If it fails, you can configure the VaultDO using the scripts available in the scripts
folder.
Generic Vault Factory
To deploy a Generic Vault Factory for the first time, run the following command:
LayerZero Setup
This setup will be executed automatically by LayerZero scripts, linking all Omnichain contracts to operate seamlessly. Run:
After executing the command, you will be prompted to select the networks you wish to deploy to (e.g., sepolia_dev, amoy_dev).
Use case deployment
When prompted to use specific deploy scripts, we must identify the use case to determine which contracts need to be deployed:
- Omnichain ERC20 With local mint and burn supply:
DiamondInitializeOmnichain, DataPointRegistry, OmnichainProxy, OmnichainFungibleTokenWithLocalMintBurnSupplyDO, OmnichainERC20WithLocalMintBurnSupplyDataManager
. - Omnichain ERC20:
DiamondInitializeOmnichain, DataPointRegistry, OmnichainProxy, OmnichainFungibleTokenDO, OmnichainERC20DataManager
.