Invariants
Note the following when using a project created viacreate-lz-oapp or when using any of the Hardhat helper tasks:
- For EVM chains, the network name set in
hardhat.config.tsmust match the folder names under/deployments - For Solana, the deployment subfolder should either be
/solana-mainnetor/solana-testnet(solana-testnetrefers 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
OFTwhen prompted. For an OFT that is both on EVM and Solana, chooseOFT (Solana). -
Create a
deploymentsfolder in the root of the repo. The eventual structure would look like this:
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-sepoliafolder 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 theaddressfield. The required ABI will be handled by step 6.
- For Solana, create a
/solana-testnetfolder 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: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.tsandlayerzero.config.tsaccordingly.
- in this example, the network name in
hardhat.config.tsshould bearbitrum-sepoliato match the folder name under/deployments. - For how to configure
layerzero.config.ts, refer to the Simple Config Generator page.
-
Run
npm run compile:hardhatto ensure relevant artifacts that are required by Hardhat helper tasks involving the EVM OFT are generated. For example, thesendhelper task when sending from an EVM chain requires theOFTartifact’s ABI. -
Run
npx hardhat lz:oapp:wire --oapp-config layerzero.config.tsand it should suggest transactions for your recreated deployments.