- TODO: add MNEMONIC to .env file
Read Whitepaper
LayerZero relies on two parties to transfer messages between on-chain endpoints:
- The Oracle &
- The Relayer
LayerZero enables devs to send secure messages across blockchains.
Omnichain Interoperability Protocol
LayerZero Endpoint has a non-reentrancy guard for both the send() and receive(), respectively. In other words, both send() and receive() can not call themselves on the same chain.
npm installnpx hardhat testconfigure an .env file to have the values of .env.example and test deploy! (Use a real LayerZero endpoint in place of 0x0000..)
- TODO: real LayerZero endpoints
- Deploy both OmniCounters:
npx hardhat --network fuji deploy
npx hardhat --network mumbai deploy
- Set the remote addresses, so each contract can receive messages
npx hardhat --network mumbai omniCounterSetRemote --target-network fuji
npx hardhat --network fuji omniCounterSetRemote --target-network mumbai
- Send a cross chain message from
mumbaitofuji!
npx hardhat --network mumbai omniCounterIncrementCounter --target-network fuji
Optionally use this command in a separate terminal to watch the counter increment in real-time.
npx hardhat --network fuji omniCounterPoll
- Deploy both OmniCounters:
npx hardhat --network mumbai deploy
npx hardhat --network fuji deploy
npx hardhat --network bsc-testnet deploy
npx hardhat --network fantom-testnet deploy
- Set the remote addresses, so each contract can receive messages
npx hardhat --network mumbai omniCounterSetRemote --target-network fuji
npx hardhat --network fuji omniCounterSetRemote --target-network mumbai
npx hardhat --network mumbai omniCounterSetRemote --target-network bsc-testnet
npx hardhat --network bsc-testnet omniCounterSetRemote --target-network mumbai
npx hardhat --network mumbai omniCounterSetRemote --target-network fantom-testnet
npx hardhat --network fantom-testnet omniCounterSetRemote --target-network mumbai
- Send a cross chain message from
mumbaitofuji!
npx hardhat --network mumbai omniCounterIncrementMultiCounter --target-networks fuji,bsc-testnet,fantom-testnet
Optionally use this command in a separate terminal to watch the counter increment in real-time.
npx hardhat --network fuji omniCounterPoll
npx hardhat --network bsc-testnet omniCounterPoll
npx hardhat --network fantom-testnet omniCounterPoll
For further reading, and a list of endpoint ids and deployed LayerZero contract addresses please take a look at the Gitbook here: https://layerzero.gitbook.io/
npx hardhat --network mumbai omniCounterGetOracle --target-network fantom-testnet
npx hardhat --network mumbai omniCounterSetOracle --target-network mumbai --oracle 0xORACLE_ADDR
test LayerZero locally using LayerZeroEndpointMock.sol