Skip to main content

Linea message bridge

Use the Linea message bridge to bridge arbitrary messages between Goerli and Linea to enable your use case.

tip

If you are bridging funds, we recommend using our bridge here.

Overview​

The Linea message bridge operates using the following patterns:

L1 to L2​

  1. The developer sends a transaction to the L1 bridge contract (implementing the IBridge.sol interface) using the dispatchMessage method.
  2. The L1 bridge contract emits a MessageDispatched event.
  3. The rollup relayer catches the event and sends an L2 transaction to the L2 bridge contract using the deliverMessage function.
  4. The L2 contract calls the contract defined in the to field. The L2 contract should authenticate the call by calling the sender() method on the L2 bridge upon reception of the deliverMessage call, and verify that this corresponds to a known L1 address.
  5. The L1 bridge contract verifies the message execution, and emits an event MessageConfirmed, once the next L2 block is finalized and the ZK proof is verified.
  6. Otherwise, the developer can drop a message after the deadline, effectively reimbursing the value that was sent.

L2 to L1​

The four first steps are identical to L1 to L2 but in the opposite direction.

  1. The developer sends a transaction to the L2 bridge contract (implementing the IBridge.sol interface) using the dispatchMessage method.
  2. The L2 bridge contract emits a MessageDispatched event.
  3. The rollup relayer catches the event and sends an L1 transaction to the L1 bridge contract using the deliverMessage function.
  4. The L1 contract calls the contract defined in the to field. The L1 contract should authenticate the call by calling the sender() method on the L1 bridge upon reception of the deliverMessage call, and verify that this corresponds to a known L1 address.
  5. The relayer embeds messages as a parameter when finalizing the block and verifying the ZK proof.

Deployed contract addresses​

The contracts are deployed at the following addresses:

Interfaces​

IBridge.sol​

IBridge.sol
// SPDX-License-Identifier: OWNED BY ConsenSys Software Inc.
pragma solidity ^0.8.15;

/// @title The bridge interface implemented on both chains
interface IBridge {
/// @notice Emitted on the origin chain when a message is to be sent to the destination chain
/// @param _from the msg.sender calling the origin bridge
/// @param _to the destination contract on the destination chain
/// @param _fee the bridge fee on the origin chain
/// @param _value the value to be transferred
/// @param _deadline timestamp as second since unix epoch after which the transaction is invalid and can be dropped
/// @param _calldata the calldata used by the destination bridge to call the destination contract
/// @dev _calldata can be calculated using abi.encodeWithSignature("transfer(address,uint256)", recipient, amount))
event MessageDispatched(
address _from,
address _to,
uint256 _fee,
uint256 _value,
uint256 _deadline,
bytes _calldata
);

/// @notice Emitted on the destination chain when a message bas been received by the destination bridge
/// @param _from the msg.sender calling the origin bridge
/// @param _to the destination contract on the destination chain
/// @param _fee the bridge fee on the origin chain
/// @param _value the value to be transferred
/// @param _deadline timestamp as second since unix epoch after which the transaction is invalid and can be dropped
/// @param _calldata the calldata used by the destination bridge to call the destination contract
/// @dev _calldata can be calculated using abi.encodeWithSignature("transfer(address,uint256)", recipient, amount))
event MessageDelivered(
address _from,
address _to,
uint256 _fee,
uint256 _value,
uint256 _deadline,
bytes _calldata
);

/// @notice Dispatches a message from the given chain. Must be called by a developer or another contract.
/// @notice If this is the L2 bridge, then this methods dispatches a message from L2 to L1.
/// @dev This function should be called with a value > _fee. The reminder will be send on the destination chain.
/// @param _to the destination contract on the destination chain
/// @param _fee the bridge fee on the origin chain
/// @param _deadline timestamp as second since unix epoch after which the transaction is invalid and can be dropped
/// @param _calldata the calldata used by the destination bridge to call the destination contract
function dispatchMessage(
address _to,
uint256 _fee,
uint256 _deadline,
bytes calldata _calldata
) external payable;

/// @notice Deliver a message to the destination chain.
/// @notice Is called automatically by the operator. Cannot be used by developers
/// @param _from the msg.sender calling the origin bridge
/// @param _to the destination contract on the destination chain
/// @param _fee the bridge fee on the origin chain
/// @param _value the value to be transferred
/// @param _deadline timestamp as second since unix epoch after which the transaction is invalid and can be dropped
/// @param _calldata the calldata used by the destination bridge to call the destination contract
function deliverMessage(
address _from,
address _to,
uint256 _fee,
uint256 _value,
uint256 _deadline,
bytes calldata _calldata
) external payable;

/// @notice When called within the context of the delivered call can be used to return the sender (_from)
/// @notice on the origin chain otherwise returns the zero address.
/// @return Address of the caller contract on the origin chain.
function sender() external view returns (address);
}

IL1Bridge.sol​

IL1Bridge.sol
// SPDX-License-Identifier: OWNED BY ConsenSys Software Inc.
pragma solidity ^0.8.15;

import 'IBridge.sol';

/// @title A specialization of the Bridge interface on the L1
interface IL1Bridge is IBridge {
/// @notice Emitted when a message has been dispatched, delivered and is now confirmed on the original chain
/// @param messageHash the hash of the message dispatched keccak256(abi.encode(from,to,fee,value,deadline,calldata))
event MessageConfirmed(bytes32 messageHash);

/// @notice Drop a message that is past its deadline and refund the sender
/// @param _from the msg.sender calling the origin bridge
/// @param _to the destination contract on the destination chain
/// @param _fee the bridge fee on the origin chain
/// @param _value the value to be transferred
/// @param _deadline timestamp as second since unix epoch after which the transaction is invalid and can be dropped
/// @param _calldata the calldata used by the destination bridge to call the destination contract
/// @dev _calldata can be calculated using abi.encodeWithSignature("transfer(address,uint256)", recipient, amount))
function dropMessage(
address _from,
address _to,
uint256 _fee,
uint256 _value,
uint256 _deadline,
bytes calldata _calldata
) external payable;
}