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

# Struct AztecConfig

Module: `noir_aztec::macros`

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

Configuration for the [`aztec`](/aztec-nr-api/v6.0.0/noir_aztec/macros/fn.aztec.md) macro.

This type lets users override different parts of the default aztec-nr contract behavior, such as message handling and state synchronization. These are advanced features that require careful understanding of the behavior of these systems.

## Examples

```rust
#[aztec(aztec::macros::AztecConfig::new().custom_message_handler(my_handler))]
contract MyContract { ... }
```

## Implementations

```rust
impl AztecConfig
```

```rust
pub comptime fn new() -> Self
```

Creates a new `AztecConfig` with default values.

Calling `new` is equivalent to invoking the [`aztec`](/aztec-nr-api/v6.0.0/noir_aztec/macros/fn.aztec.md) macro with no parameters. The different methods (e.g. [`AztecConfig::custom_message_handler`](/aztec-nr-api/v6.0.0/noir_aztec/macros/struct.AztecConfig.md#custom_message_handler)) can then be used to change the default behavior.

```rust
pub comptime fn custom_message_handler(&mut self, handler: CustomMessageHandler) -> Self
```

Sets a handler for custom messages.

This enables contracts to process non-standard messages (i.e. any with a message type that is not in [`crate::messages::msg_type`](/aztec-nr-api/v6.0.0/noir_aztec/messages/msg_type/index.md)).

`handler` must be a function that conforms to the [`crate::messages::discovery::CustomMessageHandler`](/aztec-nr-api/v6.0.0/noir_aztec/messages/discovery/type.CustomMessageHandler.md) type signature.

```rust
pub comptime fn custom_sync_state(&mut self, handler: CustomSyncHandler) -> Self
```

Overrides the default state synchronization logic.

The generated `sync_state` function will call `handler` instead of [`crate::messages::discovery::do_sync_state`](/aztec-nr-api/v6.0.0/noir_aztec/messages/discovery/fn.do_sync_state.md). The handler receives all of the same parameters, so it can run custom logic (e.g. fetching and decrypting custom logs) before, after, or instead of calling `do_sync_state`.

`handler` must be a function that conforms to the [`crate::messages::discovery::CustomSyncHandler`](/aztec-nr-api/v6.0.0/noir_aztec/messages/discovery/type.CustomSyncHandler.md) type signature.
