> For the complete documentation index, see [llms.txt](/llms.txt)

# Inbox

The `Inbox` is a contract deployed on L1 that handles message passing from L1 to L2.

**Links**: [Interface](https://github.com/AztecProtocol/aztec-packages/blob/v6.0.0/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol), [Implementation](https://github.com/AztecProtocol/aztec-packages/blob/v6.0.0/l1-contracts/src/core/messagebridge/Inbox.sol).

## `sendL2Message()`

Sends a message from L1 to L2.

```solidity
/**
 * @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](https://github.com/AztecProtocol/aztec-packages/blob/v6.0.0/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol#L67-L80)

| Name        | Type                                                                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ----------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Recipient   | [`L2Actor`](/developers/docs/foundational-topics/ethereum-aztec-messaging/data_structures.md#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`](https://github.com/AztecProtocol/aztec-packages/blob/v6.0.0/l1-contracts/src/core/libraries/crypto/Hash.sol) 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`](https://github.com/aztec-labs-eng/aztec-node/blob/v6.0.0/yarn-project/stdlib/src/hash/hash.ts) 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](/developers/docs/foundational-topics/ethereum-aztec-messaging/outbox.md) - L2 to L1 message passing
* [Data Structures](/developers/docs/foundational-topics/ethereum-aztec-messaging/data_structures.md) - Message and actor type definitions
