Rollup-to-Rollup Bridge
The ComposeL2ToL2Bridge contract is the rollup-to-rollup bridge entry point used for transferring ETH, ERC20 assets, and CET representations between Ethera rollups.
Overview
ComposeL2ToL2Bridge coordinates rollup-to-rollup transfers by:
- Locking source ERC20 assets on the source rollup when needed
- Burning CET on the source rollup when the asset is already represented as CET
- Writing bridge messages into the mailbox layer
- Receiving cross-rollup messages on the destination rollup
- Minting or releasing the correct destination representation
- Writing acknowledgment messages back through the mailbox
The contract works together with:
UniversalBridgeMailboxCETFactoryComposeETHLiquidity
Contract Interface
contract ComposeL2ToL2Bridge {
function bridgeERC20To(...) external;
function bridgeCETTo(...) external;
function bridgeEthTo(...) external payable;
function receiveTokens(...) external returns (address token, uint256 amount);
function receiveETH(...) external returns (uint256 amount);
function redeemWrappedCET(...) external;
}
Functions
bridgeERC20To(chainDest, tokenSrc, amount, receiver, sessionId)
Description: Initiates a rollup-to-rollup transfer for a non-CET ERC20 asset that is native to the source rollup.
| Parameter | Type | Description |
|---|---|---|
| chainDest | uint256 | Destination rollup chain ID |
| tokenSrc | address | Source ERC20 token address |
| amount | uint256 | Amount to bridge |
| receiver | address | Destination receiver |
| sessionId | uint256 | Unique identifier for this transfer session |
Process:
- Transfers the ERC20 into the bridge contract on the source rollup
- Reads token metadata from the source asset
- Writes a
SEND_TOKENSmessage into the mailbox - Waits for the matching acknowledgment message
Events:
TokensLocked(address indexed token, address indexed sender, uint256 amount)MailboxWrite(uint256 indexed chainId, address indexed account, uint256 indexed sessionId, string label)TokensSendQueued(uint256 indexed chainDest, address indexed sender, address indexed receiver, address remoteAsset, uint256 amount, uint256 sessionId, bytes32 messageId)
bridgeCETTo(chainDest, cetTokenSrc, amount, receiver, sessionId)
Description: Initiates a rollup-to-rollup transfer for an asset already represented as CET on the source rollup.
| Parameter | Type | Description |
|---|---|---|
| chainDest | uint256 | Destination rollup chain ID |
| cetTokenSrc | address | Source CET token address |
| amount | uint256 | Amount to bridge |
| receiver | address | Destination receiver |
| sessionId | uint256 | Unique identifier for this transfer session |
Process:
- Resolves the CET remote asset identity
- Burns the CET on the source rollup
- Writes a
SEND_TOKENSmessage into the mailbox - Waits for the matching acknowledgment message
Events:
CETBurned(address indexed token, address indexed sender, uint256 amount)MailboxWrite(uint256 indexed chainId, address indexed account, uint256 indexed sessionId, string label)TokensSendQueued(uint256 indexed chainDest, address indexed sender, address indexed receiver, address remoteAsset, uint256 amount, uint256 sessionId, bytes32 messageId)
bridgeEthTo(sessionId, chainDest, receiver)
Description: Initiates a rollup-to-rollup transfer for native ETH.
| Parameter | Type | Description |
|---|---|---|
| sessionId | uint256 | Unique identifier for this transfer session |
| chainDest | uint256 | Destination rollup chain ID |
| receiver | address | Destination receiver |
Process:
- Burns the corresponding ETH liquidity on the source side
- Writes a
SEND_ETHmessage into the mailbox - Waits for the matching acknowledgment message
Events:
ETHLocked(address indexed sender, uint256 amount)MailboxWrite(uint256 indexed chainId, address indexed account, uint256 indexed sessionId, string label)ETHBridged(uint256 indexed chainDest, address indexed sender, address indexed receiver, uint256 amount, uint256 sessionId, bytes32 messageId)
receiveTokens(msgHeader)
Description: Finalizes an incoming rollup-to-rollup token transfer on the destination rollup.
| Parameter | Type | Description |
|---|---|---|
| msgHeader | MessageHeader | Message header identifying the bridged token transfer |
Returns:
token(address): Destination token address credited on the destination rollupamount(uint256): Amount received
Process:
- Ensures the caller is the intended receiver
- Reads the bridged token message from the mailbox
- Decodes the remote asset identity and token metadata
- Releases native ERC20 if the destination rollup already holds escrowed native liquidity for that asset
- Otherwise mints the correct CET representation on the destination rollup
- Writes an
ACKmessage back through the mailbox
Events:
MailboxAckWrite(uint256 indexed chainId, address indexed account, uint256 indexed sessionId, string label)TokensReceived(address indexed token, uint256 amount)
receiveETH(msgHeader)
Description: Finalizes an incoming rollup-to-rollup ETH transfer on the destination rollup.
| Parameter | Type | Description |
|---|---|---|
| msgHeader | MessageHeader | Message header identifying the bridged ETH transfer |
Returns:
amount(uint256): Amount of ETH received
Process:
- Ensures the caller is the intended receiver
- Reads the ETH message from the mailbox
- Mints the corresponding destination-side ETH liquidity
- Sends native ETH to the receiver
- Writes an
ACKmessage back through the mailbox
Events:
MailboxAckWrite(uint256 indexed chainId, address indexed account, uint256 indexed sessionId, string label)ETHReceived(address indexed receiver, uint256 amount)
redeemWrappedCET(wrappedCET, coreCET, amount)
Description: Redeems Wrapped CET into Core CET on the same chain when a Core deployment exists for the same asset.
| Parameter | Type | Description |
|---|---|---|
| wrappedCET | address | Wrapped CET token address |
| coreCET | address | Core CET token address |
| amount | uint256 | Amount to redeem |
Process:
- Verifies that the target
coreCETis a Core CET - Verifies that the wrapped token resolves to the same remote asset
- Burns Wrapped CET
- Mints Core CET one-to-one
Events:
WrappedCETRedeemed(address indexed wrappedCET, address indexed coreCET, address indexed caller, uint256 amount)
Events
TokensSendQueued
event TokensSendQueued(uint256 indexed chainDest, address indexed sender, address indexed receiver, address remoteAsset, uint256 amount, uint256 sessionId, bytes32 messageId)
Emitted when a token transfer has been queued for mailbox delivery.
ETHBridged
event ETHBridged(uint256 indexed chainDest, address indexed sender, address indexed receiver, uint256 amount, uint256 sessionId, bytes32 messageId)
Emitted when an ETH transfer has been queued for mailbox delivery.
TokensReceived
event TokensReceived(address token, uint256 amount)
Emitted when a token transfer is finalized on the destination rollup.
ETHReceived
event ETHReceived(address receiver, uint256 amount)
Emitted when an ETH transfer is finalized on the destination rollup.
WrappedCETRedeemed
event WrappedCETRedeemed(address wrappedCET, address coreCET, address account, uint256 amount)
Emitted when Wrapped CET is redeemed into Core CET on the same chain.