IL2ToL1Messenger

Git Source

Author: Matter Labs

The interface of the L1 Messenger contract, responsible for sending messages to L1.

by default ZkSync can send fixed-length messages on L1. A fixed length message has 4 parameters senderAddress, isService, key, value, the first one is taken from the context, the other three are chosen by the sender.

*To send a variable-length message we use this trick:

  • This system contract accepts an arbitrary length message and sends a fixed length message with parameters senderAddress == this, isService == true, key == msg.sender, value == keccak256(message).
  • The contract on L1 accepts all sent messages and if the message came from this system contract it requires the preimage of value to be provided.*

Note: security-contact: security@matterlabs.dev

Functions

sendToL1

Sends an arbitrary length message to L1.

function sendToL1(bytes calldata _message) external returns (bytes32);

Parameters

NameTypeDescription
_messagebytesThe variable length message to be sent to L1.

Returns

NameTypeDescription
<none>bytes32Returns the keccak256 hashed value of the message.

sendL2ToL1Log

Sends L2ToL1Log.

Can be called only by a system contract.

function sendL2ToL1Log(bool _isService, bytes32 _key, bytes32 _value)
  external
  returns (uint256 logIdInMerkleTree);

Parameters

NameTypeDescription
_isServiceboolThe isService flag.
_keybytes32The key part of the L2Log.
_valuebytes32The value part of the L2Log.

requestBytecodeL1Publication

This function is expected to be called only by the KnownCodesStorage system contract

function requestBytecodeL1Publication(bytes32 _bytecodeHash) external;

Events

L1MessageSent

event L1MessageSent(
  address indexed _sender, bytes32 indexed _hash, bytes _message
);