This repo provides a smart contract implementation on how bridge messages to sender's address on the other network using PolygonZkEVM LxLy bridge
Private keys and mnemonics contained in this repository are used for internal test exclusively. Do not use them in production environments
- node version: 16.x
- npm version: 7.x
contracts
: zkevm contractsPolygonZkEVMBridge.sol
: transfer assets between chainsPolygonZkEVMGlobalExitRoot.sol
: manage global exit root in L1PolygonZkEVMGlobalExitRootL2.sol
: manage global exit root in L2
PolygonZkEVM.sol
: consensus algorithm used by polygon hermez zkevmSender.sol
: bridge call to another chain using PolygonZkEVMBridgeCrossChainForwarder.sol
: receive calls and forward them to sender's address
test
: contracts tests
In project root execute:
npm i
cp .env.example .env
npm run test
Fill .env
with your private key MAIN_ACCOUNT
and ALCHEMY_KEY
for every network. If you want to verify the contracts also fill the ETHERSCAN_API_KEY
and POLYGONSCAN_API_KEY
To deploy use:deploy:sender:goerli
for the sender
and deploy:forwarder:goerli
for the forwarder
. These commands will deploy two identical instances of forwarder
and sender
contract on goerli
and polygonZKEVMTestnet
at the same address and this will replace existing addresses in ./deploy/sender.json
and `./deploy/forwarder.json.
To verify contracts use npm run verify:sender:${network}
and npm run verify:forwarder:${network}
for each instance
npm run verify:sender:goerli
npm run verify:sender:polygonZKEVMTestnet
npm run verify:forwarder:goerli
npm run verify:forwarder:polygonZKEVMTestnet
In order to use the forwarder, there are already provided some scripts:
- Send call using the command bellow, it will call
bridgeMessage
onPolygonZkEVMBridge
from the origin network and bridge message toforwarder address
on the other network. the call medata is supposed to call functionsetNumber
ofcaller
on the destination network and change the value. You can change favorite number value in./scripts/bridge-call.js
npm run bridge:forwarder:goerli
- Now we have to wait until the message is forwarded to destination network, there's the final script that will check it and if it's ready will actually claim the call and forward it to
sender
address the other layer. the favoriteNumber ofcaller
contract on destination network should be the same sent while bridging the call:
npm run claim:forwarder:polygonZKEVMTestnet
- The call forwarding can also be performed from L2 to L1, we just have to we just have to swap the network arguments when executing the last two commands.