diff --git a/tools/layer-zero-example/README.md b/tools/layer-zero-example/README.md index 88bee5e3c..510f5dd17 100644 --- a/tools/layer-zero-example/README.md +++ b/tools/layer-zero-example/README.md @@ -74,7 +74,7 @@ npx hardhat deploy-erc20 --decimals 18 --mint 10000000000000000000 --network hed npx hardhat deploy-erc20 --decimals 18 --mint 10000000000000000000 --network bsc_testnet ``` -- Deploying an OFT Adapters which will be used as a lockbox of ERC20s deployed the step above +- Deploying an OFT Adapters which will be used as a lockbox of ERC20s deployed the step above, you can use an already existing HTS token as well ```typescript npx hardhat deploy-oft-adapter --token --network hedera_testnet npx hardhat deploy-oft-adapter --token --network bsc_testnet @@ -279,50 +279,6 @@ npx hardhat test --grep "HTSConnectorExistingToken @hedera @test" --network hede npx hardhat test --grep "HTSConnectorExistingToken @bsc @test" --network bsc_testnet ``` -### HTS Adapter - -If your HTS token already exists on Hedera and you want to connect it to another chain, you can deploy the OFT Adapter contract to act as an intermediary lockbox for it. - -- Deploying ERC20 and HTS -```typescript -npx hardhat create-hts-token --network hedera_testnet -npx hardhat deploy-erc20 --decimals 8 --mint 1000 --network bsc_testnet -``` - -- Deploying an OFT Adapters which will be used as lockboxes of ERC20 and HTS deployed the step above -```typescript -npx hardhat deploy-oft-adapter --token --network hedera_testnet -npx hardhat deploy-oft-adapter --token --network bsc_testnet -``` - -- In order to connect OFT Adapters together, we need to set the peer of the target OFT Adapter, more info can be found here https://docs.layerzero.network/v2/developers/evm/getting-started#connecting-your-contracts -```typescript -npx hardhat set-peer --source --target --network hedera_testnet -npx hardhat set-peer --source --target --network bsc_testnet -``` - -- Fill the .env - -- Here we're funding the Adapter on both chains with some liquidity and after that we're approving it to spend the signer's token -```typescript -npx hardhat test --grep "HTSAdapterTests @hedera @fund-and-approve" --network hedera_testnet -npx hardhat test --grep "HTSAdapterTests @bsc @fund-and-approve" --network bsc_testnet -``` - -- On these steps, we're sending already existing tokens that are used by OFT Adapter between different chains -```typescript -npx hardhat test --grep "HTSAdapterTests @hedera @send" --network hedera_testnet -npx hardhat test --grep "HTSAdapterTests @bsc @send" --network bsc_testnet -``` - -- Wait a couple of minutes, the LZ progress can be tracked on `https://testnet.layerzeroscan.com/tx/` - -- Finally we're checking whether the tokens are transferred successfully -```typescript -npx hardhat test --grep "HTSAdapterTests @hedera @test" --network hedera_testnet -npx hardhat test --grep "HTSAdapterTests @bsc @test" --network bsc_testnet -``` - ### WHBAR flow Wrap and transfer HBARs across different chains. diff --git a/tools/layer-zero-example/hardhat.config.js b/tools/layer-zero-example/hardhat.config.js index 0c28dbf9a..4f828f4e1 100644 --- a/tools/layer-zero-example/hardhat.config.js +++ b/tools/layer-zero-example/hardhat.config.js @@ -20,6 +20,7 @@ require('dotenv').config(); require('@nomicfoundation/hardhat-toolbox'); +const CONSTANTS = require('./test/constants'); module.exports = { solidity: { @@ -225,9 +226,9 @@ task('set-peer', 'Set peer') let EID; if (hre.network.name === 'hedera_testnet') { - EID = 40102; + EID = CONSTANTS.BSC_EID; } else if (hre.network.name === 'bsc_testnet') { - EID = 40285; + EID = CONSTANTS.HEDERA_EID; } const contract = await ethers.getContractAt('ExampleOApp', taskArgs.source);