Skip to main content

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:

  • UniversalBridgeMailbox
  • CETFactory
  • ComposeETHLiquidity

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.

ParameterTypeDescription
chainDestuint256Destination rollup chain ID
tokenSrcaddressSource ERC20 token address
amountuint256Amount to bridge
receiveraddressDestination receiver
sessionIduint256Unique identifier for this transfer session

Process:

  1. Transfers the ERC20 into the bridge contract on the source rollup
  2. Reads token metadata from the source asset
  3. Writes a SEND_TOKENS message into the mailbox
  4. 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.

ParameterTypeDescription
chainDestuint256Destination rollup chain ID
cetTokenSrcaddressSource CET token address
amountuint256Amount to bridge
receiveraddressDestination receiver
sessionIduint256Unique identifier for this transfer session

Process:

  1. Resolves the CET remote asset identity
  2. Burns the CET on the source rollup
  3. Writes a SEND_TOKENS message into the mailbox
  4. 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.

ParameterTypeDescription
sessionIduint256Unique identifier for this transfer session
chainDestuint256Destination rollup chain ID
receiveraddressDestination receiver

Process:

  1. Burns the corresponding ETH liquidity on the source side
  2. Writes a SEND_ETH message into the mailbox
  3. 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.

ParameterTypeDescription
msgHeaderMessageHeaderMessage header identifying the bridged token transfer

Returns:

  • token (address): Destination token address credited on the destination rollup
  • amount (uint256): Amount received

Process:

  1. Ensures the caller is the intended receiver
  2. Reads the bridged token message from the mailbox
  3. Decodes the remote asset identity and token metadata
  4. Releases native ERC20 if the destination rollup already holds escrowed native liquidity for that asset
  5. Otherwise mints the correct CET representation on the destination rollup
  6. Writes an ACK message 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.

ParameterTypeDescription
msgHeaderMessageHeaderMessage header identifying the bridged ETH transfer

Returns:

  • amount (uint256): Amount of ETH received

Process:

  1. Ensures the caller is the intended receiver
  2. Reads the ETH message from the mailbox
  3. Mints the corresponding destination-side ETH liquidity
  4. Sends native ETH to the receiver
  5. Writes an ACK message 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.

ParameterTypeDescription
wrappedCETaddressWrapped CET token address
coreCETaddressCore CET token address
amountuint256Amount to redeem

Process:

  1. Verifies that the target coreCET is a Core CET
  2. Verifies that the wrapped token resolves to the same remote asset
  3. Burns Wrapped CET
  4. 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.