Guides

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:

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:

source GITHUB_TOKEN=your_personal_token

2. Install dependencies

Install dependencies required for the deployment:

yarn & yarn install
git submodule init
git submodule update

3. Build contracts

Begin building the contracts by running the following command:

yarn build

4. Tests

To run the tests, execute the following command:

yarn test

Note

Ensure that a .npmrc file is present in your root directory.

#.npmrc
registry=https://registry.yarnpkg.com/
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@nexeraprotocol:registry=https://npm.pkg.github.com
@evergonlabs:registry=https://npm.pkg.github.com
always-auth=true

Note

Ensure that a .yarnrc.yaml file is present in your root directory.

nodeLinker: node-modules
npmScopes:
  nexeraprotocol:
    npmAuthToken: "${GITHUB_TOKEN}"
    npmRegistryServer: "https://npm.pkg.github.com"
  evergonlabs:
    npmAuthToken: "${GITHUB_TOKEN}"
    npmRegistryServer: "https://npm.pkg.github.com"

If you wish to run linting or check the contract sizes run these commands:

# Lint (Smart contracts and TS files)
yarn lint

# Checking contracts size
yarn contract-size

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:

yarn deploy:core_omnichain --network <chain1_name>

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.

npx hardhat lz:oapp:wire --oapp-config testnet.layerzero.config.ts

To complete the proxy configuration, let's run the ODC-specific Omnichain configuration.

For chain 1:

yarn configOmnichainProxy --network <network_name1> --destnetwork <network_name2>

For chain 2, we need to run the same command, but with the network names switched:

yarn configOmnichainProxy --network <network_name2> --destnetwork <network_name1>

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:

yarn allocateDataPoint --network <chain1_name>
yarn setFungibleDataObjectImpl_LocalMintBurn --network <chain1_name> --dp <datapoint>
yarn deploy:ERC20WithLocalMint_omnichain --network <chain1_name>
yarn approveOmnichainDataManager --dm <DM_Address> --chainid chainID_1 --dp <datapoint> --network <chain_1_name>

In chain 2:

yarn deploy:ERC20WithLocalMint_omnichain --network <chain2_name>

Approves a local DataManager for a remote DataPoint (on chain 1):

yarn approveOmnichainDataManager --dm <DM_Address> --chainid chainID_2 --dp <datapoint> --network <chain_1_name>

If registering the increase balancer fails, re-run the process with the following command:

yarn registerOmnichainIncreaseBalanceHandler --network <chain_1_name>

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:

yarn deploy:OmnichainFungibleTokenWithLocalMintBurnSupplyDO --network <network_name>

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.

yarn configOmnichainFungibleDO --network <network_name1> --dp <datapoint_chain1> --originchainid <origin_chainid> --destchainid <destination_chainid>

In chain 2:

yarn configOmnichainFungibleDO --network <network_name2> --dp <datapoint_chain1> --originchainid <origin_chainid> --destchainid <destination_chainid>

Vault Data Object

To deploy a Vault Data Object for the first time, run the following command:

yarn deploy:VaultDataObject --network <network_name>

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:

yarn deploy:GenericVaultFactory --network <network_name>

LayerZero Setup

This setup will be executed automatically by LayerZero scripts, linking all Omnichain contracts to operate seamlessly. Run:

npx hardhat lz:deploy

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.