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

# Struct NoteMetadata

Module: `noir_aztec::note::note_metadata`

```rust
pub struct NoteMetadata
{ /* private fields */ }
```

The metadata required to both prove a note's existence and destroy it, by computing the correct note hash for kernel read requests, as well as the correct nullifier to avoid double-spends.

This represents a note in any of the three valid stages (pending same phase, pending previous phase, or settled). In order to access the underlying fields callers must first find the appropriate stage (e.g. via `is_settled()`) and then convert this into the appropriate type (e.g. via `to_settled()`).

## Implementations

```rust
impl NoteMetadata
```

```rust
pub fn from_raw_data(nonzero_note_hash_counter: bool, maybe_note_nonce: Field) -> Self
```

Constructs a `NoteMetadata` object from optional note hash counter and nonce. Both a zero note hash counter and a zero nonce are invalid, so those are used to signal non-existent values.

```rust
pub fn is_pending_same_phase(self) -> bool
```

Returns `true` if the note is pending **and** from the same phase, i.e. if it's been created in the current transaction during the current execution phase (either non-revertible or revertible).

```rust
pub fn is_pending_previous_phase(self) -> bool
```

Returns `true` if the note is pending **and** from the previous phase, i.e. if it's been created in the current transaction during an execution phase prior to the current one. Because private execution only has two phases with strict ordering, this implies that the note was created in the non-revertible phase, and that the current phase is the revertible phase.

```rust
pub fn is_settled(self) -> bool
```

Returns `true` if the note is settled, i.e. if it's been created in a prior transaction and is therefore already in the note hash tree.

```rust
pub fn to_pending_same_phase(self) -> PendingSamePhaseNoteMetadata
```

Asserts that the metadata is that of a pending note from the same phase and converts it accordingly.

```rust
pub fn to_pending_previous_phase(self) -> PendingPreviousPhaseNoteMetadata
```

Asserts that the metadata is that of a pending note from a previous phase and converts it accordingly.

```rust
pub fn to_settled(self) -> SettledNoteMetadata
```

Asserts that the metadata is that of a settled note and converts it accordingly.

## Trait implementations

```rust
impl Deserialize for NoteMetadata
```

```rust
pub fn deserialize(fields: [Field; 2]) -> Self
```

```rust
pub fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self
```

```rust
impl Eq for NoteMetadata
```

```rust
pub fn eq(_self: Self, _other: Self) -> bool
```

```rust
impl From<PendingPreviousPhaseNoteMetadata> for NoteMetadata
```

```rust
pub fn from(value: PendingPreviousPhaseNoteMetadata) -> Self
```

```rust
impl From<PendingSamePhaseNoteMetadata> for NoteMetadata
```

```rust
pub fn from(_value: PendingSamePhaseNoteMetadata) -> Self
```

```rust
impl From<SettledNoteMetadata> for NoteMetadata
```

```rust
pub fn from(value: SettledNoteMetadata) -> Self
```

```rust
impl Packable for NoteMetadata
```

```rust
pub fn pack(self) -> [Field; 2]
```

```rust
pub fn unpack(packed: [Field; 2]) -> Self
```

```rust
impl Serialize for NoteMetadata
```

```rust
pub fn serialize(self) -> [Field; 2]
```

```rust
pub fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>)
```
