> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Function encode_message

Module: `noir_aztec::messages::encoding`

```rust
pub fn encode_message<let N: u32>(
    msg_type: u64,
    msg_metadata: u64,
    msg_content: [Field; N],
) -> [Field; N + 1]
```

Encodes a message following aztec-nr's standard message encoding. This message can later be decoded with `decode_message` to retrieve the original values.

- The `msg_type` is an identifier that groups types of messages that are all processed the same way, e.g. private notes or events. Possible values are defined in `aztec::messages::msg_type`.
- The `msg_metadata` and `msg_content` are the values stored in the message, whose meaning depends on the `msg_type`. The only special thing about `msg_metadata` that separates it from `msg_content` is that it is a u64 instead of a full Field (due to details of how messages are encoded), allowing applications that can fit values into this smaller variable to achieve higher data efficiency.
