Auto-generated documentation.
Send some ETH along with data from one chain to another chain.
polycli ulxly bridge message [flags]This command is very similar to polycli ulxly bridge asset, but instead this is a more generic interface that can be used to transfer ETH and make a contract call. This is the underlying solidity interface that we're referencing.
/**
* @notice Bridge message and send ETH value
* note User/UI must be aware of the existing/available networks when choosing the destination network
* @param destinationNetwork Network destination
* @param destinationAddress Address destination
* @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not
* @param metadata Message metadata
*/
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external payable ifNotEmergencyState {The source code for this particular method is here.
Below is a simple example of using this command to bridge a small amount of ETH from Sepolia (L1) to Cardona (L2). In this case, we're not including any call data, so it's essentially equivalent to a bridge asset call, but the deposit will not be automatically claimed on L2.
polycli ulxly bridge message \
--bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \
--private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b \
--destination-network 1 \
--value 10000000000000000 \
--rpc-url https://sepolia.drpc.orgThis is the transaction that was generated and mined from this command.
In most cases, you'll want to specify some call-data and a destination-address in order for a contract to be called on the destination chain. For example:
polycli ulxly bridge message \
--bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \
--private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b \
--destination-network 1 \
--destination-address 0xC92AeF5873d058a76685140F3328B0DED79733Af \
--call-data 0x40c10f190000000000000000000000003878cff9d621064d393eef92bf1e12a944c5ba84000000000000000000000000000000000000000000000000002386f26fc10000 \
--value 0 \
--rpc-url https://sepolia.drpc.orgThis is the transaction that was created and mined from running the above command.
In this case, I've configured the destination address to be a test contract I've deployed on L2.
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
contract MessageEmitter {
event MessageReceived (address originAddress, uint32 originNetwork, bytes data);
function onMessageReceived(address originAddress, uint32 originNetwork, bytes memory data) external payable {
emit MessageReceived(originAddress, originNetwork, data);
}
}
The idea is to have minimal contract that will meet the expected interface of the bridge contract: https://github.com/0xPolygonHermez/zkevm-contracts/blob/v9.0.0-rc.3-pp/contracts/interfaces/IBridgeMessageReceiver.sol
In this case, I didn't bother implementing the proxy to an ERC20 or extending some ERC20 contract. I'm just emitting an event to know that the transaction actually fired as expected.
The calldata comes from running this command cast calldata 'mint(address account, uint256 amount)' 0x3878Cff9d621064d393EEF92bF1e12A944c5ba84 10000000000000000. Again, in this case no ERC20 will be minted because I didn't set it up.
-h, --help help for messageThe command also inherits flags from parent commands.
--bridge-address string address of the lxly bridge
--call-data string call data to be passed directly with bridge-message or as an ERC20 Permit (default "0x")
--call-data-file string a file containing hex encoded call data
--chain-id string chain ID to use in the transaction
--config string config file (default is $HOME/.polygon-cli.yaml)
--destination-address string destination address for the bridge
--destination-network uint32 rollup ID of the destination network
--dry-run do all of the transaction steps but do not send the transaction
--force-update-root update the new global exit root (default true)
--gas-limit uint force specific gas limit for transaction
--gas-price string gas price to use
--insecure skip TLS certificate verification
--legacy force usage of legacy bridge service (default true)
--pretty-logs output logs in pretty format instead of JSON (default true)
--private-key string hex encoded private key for sending transaction
--rpc-url string RPC URL to send the transaction
--token-address string address of ERC20 token to use (default "0x0000000000000000000000000000000000000000")
--transaction-receipt-timeout uint timeout in seconds to wait for transaction receipt confirmation (default 60)
--value string amount in wei to send with the transaction (default "0")
-v, --verbosity string log level (string or int):
0 - silent
100 - panic
200 - fatal
300 - error
400 - warn
500 - info (default)
600 - debug
700 - trace (default "info")- polycli ulxly bridge - Commands for moving funds and sending messages from one chain to another.