Skip to content

Commit

Permalink
feat: remove duplicated OFT Adapter section in LZ readme (#3397)
Browse files Browse the repository at this point in the history
* chore: edit readme

Signed-off-by: nikolay <[email protected]>

* chore: pull main

Signed-off-by: nikolay <[email protected]>

* chore: fix hardhat config

Signed-off-by: nikolay <[email protected]>

---------

Signed-off-by: nikolay <[email protected]>
  • Loading branch information
natanasow authored Jan 17, 2025
1 parent 9229d1e commit 0fc6680
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 47 deletions.
46 changes: 1 addition & 45 deletions tools/layer-zero-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <erc20_hedera_address> --network hedera_testnet
npx hardhat deploy-oft-adapter --token <erc20_bsc_address> --network bsc_testnet
Expand Down Expand Up @@ -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 <hts_token_address> --network hedera_testnet
npx hardhat deploy-oft-adapter --token <erc20_bsc_address> --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 <hedera_oft_adapter_address> --target <bsc_oft_adapter_address> --network hedera_testnet
npx hardhat set-peer --source <bsc_oft_adapter_address> --target <hedera_oft_adapter_address> --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/<tx_hash>`

- 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.
Expand Down
5 changes: 3 additions & 2 deletions tools/layer-zero-example/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

require('dotenv').config();
require('@nomicfoundation/hardhat-toolbox');
const CONSTANTS = require('./test/constants');

module.exports = {
solidity: {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0fc6680

Please sign in to comment.