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).
-
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, chooseOFT (Solana)
. -
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.
- 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. -
/arbitrum-sepolia/MyOFT.json
- this is where the OFT's address is set. The only key that is necessary in the JSON file isaddress
. You can see a sample of that below, insert your OFT address into theaddress
field. The required ABI will be handled by step 6.{
"address": ""
}
- For Solana, 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": "",
"mint": "",
"mintAuthority": "",
"escrow": "",
"oftStore": ""
}Given the Solana OFT Store address, you can run
npx hardhat lz:oft:store:debug --oft-store <OFT_STORE> --eid <SOLANA_EID>
to view debug information that contains the relevant Solana addresses.
- Modify
hardhat.config.ts
andlayerzero.config.ts
accordingly.
- in this example, the network name in
hardhat.config.ts
should bearbitrum-sepolia
to match the folder name under/deployments
. - For how to configure
layerzero.config.ts
, refer to the Simple Config Generator page.
-
Run
npm run compile:hardhat
to ensure relevant artifacts that are required by Hardhat helper tasks involving the EVM OFT are generated. For example, thesend
helper task when sending from an EVM chain requires theOFT
artifact's ABI. -
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