Skip to main content
Version: Endpoint V2

Recreating Deployments

This guide is intended for situations where you might have lost access to the original project code, or the deployment was made outside of a project initialized by create-lz-oapp. It explains how to reconstruct the expected deployments layout so you can use the Hardhat helper tasks.

Under the hood, create-lz-oapp uses Hardhat Deploy v1 to manage deployments. All EVM deployments follow Hardhat Deploy's conventions.

Invariants

Note the following when using a project created via create-lz-oapp or when using any of the Hardhat helper tasks:

  • For EVM chains, the network name set in hardhat.config.ts must match the folder names under /deployments
  • For Solana, the deployment subfolder should either be /solana-mainnet or /solana-testnet (solana-testnet refers to Solana Devnet)

Recreate Deployments

For this example, we'll recreate deployments for an OFT that was deployed on Arbitrum Sepolia and Solana Devnet. Before following the steps, you need to at least have the address of the OFT on Arbitrum Sepolia, and the OFT Store address on Solana Devnet (not the Mint Address).

  1. Create a new project - Create a new project using the create-lz-oapp CLI. For an EVM-only OFT, you can choose OFT when prompted. For an OFT that is both on EVM and Solana, choose OFT (Solana).

  2. Create the deployments folder - Create a deployments folder in the root of the repo. The eventual structure would look like this:

    /deployments
    /arbitrum-sepolia
    .chainId
    MyOFT.json
    /solana-testnet
    OFT.json

For the EVM chain deployments, if you previously deployed using Hardhat Deploy, simply copy over the contents of the deployments folder from your previous project.

  1. Set up EVM chain deployments - Under /deployments, for the EVM chain (Arbitrum Sepolia in this example), create an /arbitrum-sepolia folder which contains:
  • /arbitrum-sepolia/.chainId - this file should contain the chain ID for the network, and not the Endpoint ID. Chain IDs can be found in the table here. For this example, .chainId will contain 421614, which is the chainId for Arbitrum Sepolia.

    421614
  • /arbitrum-sepolia/MyOFT.json - this is where the OFT's address is set. The only two keys that are necessary in the JSON file are address and abi. You can see a sample of that below, insert your OFT address into the address field. For the abi field, you can specify an empty array.

    {
    "address": "<OFT_ADDRESS>",
    "abi": []
    }

    You can also paste in the actual abi array above, which would be necessary if you have implemented a custom or extended OFT interface.

  1. Set up Solana deployments (Solana only) - Create a /solana-testnet folder which contains:
  • /solana-testnet/OFT.json - in here are several addresses required by the Solana OFT. Below is an example of a full file with all the necessary keys:

    {
    "programId": "<OFT_PROGRAM_ID>",
    "mint": "<MINT_ADDRESS>",
    "mintAuthority": "<MINT_AUTHORITY>",
    "escrow": "<ESCROW>",
    "oftStore": "<OFT_STORE>"
    }

    Given the Solana OFT Store address, you can run npx hardhat lz:oft:solana:debug --oft-store <OFT_STORE> --eid <SOLANA_EID> to view debug information that contains the relevant Solana addresses that you can copy to populate the above OFT.json.

  1. Configure Hardhat and LayerZero - Modify hardhat.config.ts and layerzero.config.ts accordingly.
  • in this example, the network name in hardhat.config.ts should be arbitrum-sepolia to match the folder name under /deployments.
  • For how to configure layerzero.config.ts, refer to the Simple Config Generator page.
  1. Compile Hardhat artifacts - Run npm run compile:hardhat to ensure relevant artifacts that are required by Hardhat helper tasks involving the EVM OFT are generated. For example, the send helper task when sending from an EVM chain requires the OFT artifact's ABI.

    If in Step 3 you had pasted in your actual ABI rather than an empty array, you can skip this step.

  2. Run the wire command - Run npx hardhat lz:oapp:wire --oapp-config layerzero.config.ts and it should suggest transactions for your recreated deployments.

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