yarn install
prepare a new wallet that never send tx on any chain before, in order to keep all contracts with the same address on all chains.
WARNING: You must perform the setTrustedRemote() (step 3).
- Fill out .env:
MNEMONIC="test test test test test test test test test test test test"
- Deploy two contracts:
$ npx hardhat --network bsc-testnet deploy --tags BlockHashSend
$ npx hardhat --network fuji deploy --tags BlockHashReceive
- Set the "trusted remotes" (ie: your contracts) so each of them can receive messages from one another, and
only
one another.
$ npx hardhat --network bsc-testnet setTrustedRemote --target-network bsc-testnet --src-contract-name BlockHashSend --dst-contract-name BlockHashSend
$ npx hardhat --network bsc-testnet setTrustedRemote --target-network fuji --src-contract-name BlockHashSend --dst-contract-name BlockHashReceive
$ npx hardhat --network fuji setTrustedRemote --target-network bsc-testnet --src-contract-name BlockHashReceive --dst-contract-name BlockHashSend
- Send a loop back from
bsc-testnet
tobsc-testnet
containing the block number. Then on lzReceive inbsc-testnet
, use the block number to get the blockhash and then send tofuji
. Whenfuji
gets the transaction it will store it into an array.
$ npx hardhat --network bsc-testnet sendBlockNumber --target-network fuji
- On
fuji
check that the blockhash is stored in the contract.
$ npx hardhat --network fuji getBlockHash
- On
bsc-testnet
get the block using the blockhash
$ npx hardhat --network bsc-testnet getBlock --blockhash BLOCKHASH