IL2ToL1Messenger
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
Name | Type | Description |
---|---|---|
_message | bytes | The variable length message to be sent to L1. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | Returns 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
Name | Type | Description |
---|---|---|
_isService | bool | The isService flag. |
_key | bytes32 | The key part of the L2Log. |
_value | bytes32 | The 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
);