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

# Struct SinglePrivateImmutable

Module: `noir_aztec::state_vars`

```rust
pub struct SinglePrivateImmutable<Note, Context>
{ /* private fields */ }
```

Contract-wide immutable private state.

A state variable that holds a single private value that is set once and remains unchanged forever (unlike [`crate::state_vars::private_immutable::PrivateImmutable`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.PrivateImmutable.md), which holds one private value *per account* - hence the name 'single').

Because this private value has no semantic owner, it is up to the application to determine which accounts will learn of its existence via [`crate::note::note_message::NoteMessage::deliver_to`](/aztec-nr-api/v6.0.0/noir_aztec/note/struct.NoteMessage.md#deliver_to).

## Usage

Unlike [`crate::state_vars::private_immutable::PrivateImmutable`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.PrivateImmutable.md) which is "owned" (requiring wrapping in an [`crate::state_vars::owned::Owned`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.Owned.md) state variable), SinglePrivateImmutable is used directly in storage:

```rust
#[storage]
struct Storage<Context> {
    your_variable: SinglePrivateImmutable<YourNote, Context>,
}
```

## Example

A contract's configuration parameters can be represented as a SinglePrivateImmutable. Once set during contract deployment or initial setup, these parameters remain constant for the lifetime of the contract. For example, an account contract's signing public key is typically stored using SinglePrivateImmutable. Note that the configuration would be visible only to the parties to which the [`NoteMessage`](/aztec-nr-api/v6.0.0/noir_aztec/note/struct.NoteMessage.md) returned from the `initialize(...)` function is delivered.

## Requirements

The contract that holds this state variable must have keys associated with it. This is because the initialization nullifier includes the contract's nullifier hiding key (nhk) in its preimage and because the contract is set as the owner of the underlying note. This is expected to not ever be a problem because the contracts that use SinglePrivateImmutable generally have keys associated with them (account contracts or escrow contracts).

## Implementations

```rust
impl<Note, Context> SinglePrivateImmutable<Note, Context>
```

```rust
impl<Note> SinglePrivateImmutable<Note, &mut PrivateContext>
```

```rust
pub fn initialize(self, note: Note) -> NoteMessage<Note>
where
    Note: NoteType,
    Note: NoteHash,
    Note: Packable
```

Initializes a SinglePrivateImmutable state variable instance with a permanent `note` and returns a [`NoteMessage`](/aztec-nr-api/v6.0.0/noir_aztec/note/struct.NoteMessage.md) that allows you to decide what method of note message delivery to use.

This function inserts the single, permanent note for this state variable. It can only be called once per SinglePrivateImmutable. Subsequent calls will fail because the initialization nullifier will already exist.

```rust
pub fn get_note(self) -> Note
where
    Note: NoteType,
    Note: NoteHash,
    Note: Packable
```

Reads the permanent note of a SinglePrivateImmutable state variable instance.

If this SinglePrivateImmutable state variable has not yet been initialized, no note will exist: the call will fail and the transaction will not be provable.

Since the note is immutable, there's no risk of reading stale data or race conditions - the note never changes after initialization.

```rust
impl<Note> SinglePrivateImmutable<Note, UtilityContext>
where
    Note: NoteType,
    Note: NoteHash,
    Note: Eq
```

```rust
pub unconstrained fn is_initialized(self) -> bool
```

Returns `true` if this SinglePrivateImmutable has been initialized.

```rust
pub unconstrained fn view_note(self) -> Note
where
    Note: Packable
```

Returns the permanent note in this SinglePrivateImmutable state variable instance.

## Trait implementations

```rust
impl<Context, Note> StateVariable<1, Context> for SinglePrivateImmutable<Note, Context>
```

```rust
pub fn new(context: Context, storage_slot: Field) -> Self
```

```rust
pub fn get_storage_slot(self) -> Field
```
