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

# Type alias ComputeNoteHash

Module: `noir_aztec::messages::discovery`

```rust
pub type ComputeNoteHash = unconstrained fn(BoundedVec<Field, 8>, AztecAddress, Field, Field, AztecAddress, Field) -> Option<Field>;
```

A contract's way of computing note hashes.

Each contract in the network is free to compute their note's hash as they see fit - the hash function itself is not enshrined or standardized. Some aztec-nr functions however do need to know the details of this computation (e.g. when finding new notes), which is what this type represents.

This function takes a note's packed content, storage slot, note type ID, address of the emitting contract and randomness, and attempts to compute its inner note hash (not siloed by address nor uniqued by nonce).

## Transient Notes

This function is meant to always be used on **settled** notes, i.e. those that have been inserted into the trees and for which the nonce is known. It is never invoked in the context of a transient note, as those are not involved in message processing.

## Automatic Implementation

The [`[#aztec]`](/aztec-nr-api/v6.0.0/noir_aztec/macros/fn.aztec.md) macro automatically creates a correct implementation of this function for each contract by inspecting all note types in use and the storage layout. This injected function is a `#[contract_library_method]` called `_compute_note_hash`, and it looks something like this:

```rust
|packed_note, owner, storage_slot, note_type_id, _contract_address, randomness| {
    if note_type_id == MyNoteType::get_id() {
        if packed_note.len() != MY_NOTE_TYPE_SERIALIZATION_LENGTH {
            Option::none()
        } else {
            let note = MyNoteType::unpack(aztec::utils::array::subarray(packed_note.storage(), 0));
            Option::some(note.compute_note_hash(owner, storage_slot, randomness))
        }
    } else if note_type_id == MyOtherNoteType::get_id() {
          ... // Similar to above but calling MyOtherNoteType::unpack
    } else {
        Option::none() // Unknown note type ID
    };
}
```
