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

# Function view

Module: `noir_aztec::macros::functions`

```rust
pub comptime fn view(f: FunctionDefinition)
```

View functions cannot modify state in any way, including performing contract calls that would in turn modify state.

This makes them easy to reason about: they are simply 'pure' functions that return a value, and carry e.g. no reentrancy risk.

## Use Cases

Only public and private functions can be [`view`](/aztec-nr-api/v6.0.0/noir_aztec/macros/functions/fn.view.md).

Private [`view`](/aztec-nr-api/v6.0.0/noir_aztec/macros/functions/fn.view.md) functions are typically not very useful as they cannot emit nullifiers, which is often required when reading private state (e.g. from a [`crate::state_vars::private_mutable::PrivateMutable`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.PrivateMutable.md) or [`crate::state_vars::private_set::PrivateSet`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.PrivateSet.md) state variable). They do however have their use cases, such as performing a [`crate::state_vars::delayed_public_mutable::DelayedPublicMutable`](/aztec-nr-api/v6.0.0/noir_aztec/state_vars/struct.DelayedPublicMutable.md) read.

Public view functions on the other hand are very common, since reading public storage does not require any state modifications. These are essentially equivalent to a Solidity `view` function.

## Guarantees

[`view`](/aztec-nr-api/v6.0.0/noir_aztec/macros/functions/fn.view.md) functions can *only* be called in a static execution context, which is typically achieved by calling the [`crate::contract_self::ContractSelfPublic::view`](/aztec-nr-api/v6.0.0/noir_aztec/contract_self/contract_self_public/struct.ContractSelfPublic.md#view) method on `self`.

No compile time checks are performed on whether a function can be made [`view`](/aztec-nr-api/v6.0.0/noir_aztec/macros/functions/fn.view.md). If a function marked as view attempts to modify state, that will result in *runtime* failures.
