Inbox
The Inbox is a contract deployed on L1 that handles message passing from L1 to L2.
Links: Interface, Implementation.
sendL2Message()
Sends a message from L1 to L2.
send_l1_to_l2_message
/**
* @notice Inserts a new message into the Inbox
* @dev Emits `MessageSent` with data for easy access by the sequencer
* @param _recipient - The recipient of the message
* @param _content - The content of the message (application specific)
* @param _secretHash - The secret hash of the message (make it possible to hide when a specific message is consumed
* on L2)
* @return The key of the message in the set and its compact cumulative index
*/
function sendL2Message(DataStructures.L2Actor memory _recipient, bytes32 _content, bytes32 _secretHash)
external
returns (bytes32, uint256);
Source code: l1-contracts/src/core/interfaces/messagebridge/IInbox.sol#L67-L80
| Name | Type | Description |
|---|---|---|
| Recipient | L2Actor | The recipient of the message. The recipient's version MUST match the inbox version and the actor must be an Aztec contract that is attached to the contract making this call. If the recipient is not attached to the caller, the message cannot be consumed by it. |
| Content | field (~254 bits) | The content of the message. This is the data that will be passed to the recipient. The content is limited to a single field for rollup purposes. If the content is small enough it can be passed directly, otherwise it should be hashed and the hash passed along (you can use our Hash utilities with sha256ToField functions). |
| Secret Hash | field (~254 bits) | A hash of a secret used when consuming the message on L2. Keep this preimage secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed). Use computeSecretHash to compute it from a secret. |
| ReturnValue | (bytes32, uint256) | The message hash (used as an identifier) and the leaf index in the tree. |
Edge cases
- Will revert with
Inbox__ActorTooLarge(bytes32 actor)if the recipient actor is larger than the field size (~254 bits). - Will revert with
Inbox__VersionMismatch(uint256 expected, uint256 actual)if the recipient version doesn't match the inbox version. - Will revert with
Inbox__ContentTooLarge(bytes32 content)if the content is larger than the field size (~254 bits). - Will revert with
Inbox__SecretHashTooLarge(bytes32 secretHash)if the secret hash is larger than the field size (~254 bits).
View functions
These functions allow you to query the current state of the Inbox.
| Function | Returns | Description |
|---|---|---|
getState() | InboxState | Returns the current inbox state (rolling hash, total messages inserted). |
getTotalMessagesInserted() | uint64 | Returns the total number of messages inserted into the inbox. |
getFeeAssetPortal() | address | Returns the address of the Fee Juice portal. |
Related pages
- Outbox - L2 to L1 message passing
- Data Structures - Message and actor type definitions