Skip to content

Commit 4cbe818

Browse files
authored
docs: document defi-wonderland immutable macro (#21764)
## Summary - Adds documentation for the [aztec-immutables-macro](https://github.com/defi-wonderland/aztec-immutables-macro/tree/dev) library that encodes immutable values into the contract deployment salt, eliminating initialization transactions - Adds the page to both current developer docs and v4.1.0-rc.2 versioned docs ## Test plan - [ ] Verify page renders correctly with `yarn start` in docs/ - [ ] Confirm the page appears in the v4.1.0-rc.2 version dropdown under Aztec.nr > Framework Description - [ ] Verify external links to the macro repo are valid 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 803e4cb + 0d3526f commit 4cbe818

File tree

2 files changed

+66
-0
lines changed
  • docs
    • developer_versioned_docs/version-v4.1.0-rc.2/docs/aztec-nr/framework-description
    • docs-developers/docs/aztec-nr/framework-description

2 files changed

+66
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Immutables via Salt
3+
sidebar_position: 4
4+
tags: [contracts, storage, immutables, optimization]
5+
description: Commit immutable values into a contract's address salt, eliminating initialization transactions.
6+
---
7+
8+
Aztec contracts can commit immutable values directly into the contract's address by encoding them into the deployment salt, removing the need for a separate initialization transaction.
9+
10+
## Overview
11+
12+
Rather than storing immutables in private storage (which requires an initializer function and an extra transaction), the [aztec-immutables-macro](https://github.com/defi-wonderland/aztec-immutables-macro/tree/dev) library encodes them into the contract's salt:
13+
14+
```
15+
salt = poseidon2_hash([actual_salt, constant_0, constant_1, ...])
16+
```
17+
18+
Since the salt is part of the address derivation, the immutable values become cryptographically bound to the contract's address itself.
19+
20+
## Key benefits
21+
22+
- **No initialization transaction** — immutables are committed at deployment time, not in a separate setup call
23+
- **Runtime verification** — at execution time, capsule data is loaded and verified against the stored salt, ensuring data integrity
24+
- **Persistent storage** — immutables are persisted to the PXE's [CapsuleStore](./advanced/how_to_use_capsules.md) after deployment, so capsules don't need to be attached to every transaction
25+
- **Compatible with standard storage** — works alongside `#[storage]` and initializers when needed
26+
27+
## Performance
28+
29+
Initialization cost is completely eliminated (no constructor transaction). The per-transaction overhead is approximately 1,098 gates (+0.2%) in the account entrypoint.
30+
31+
## Getting started
32+
33+
For installation instructions, usage examples, and a reference implementation of an initializerless Schnorr account contract, see the [aztec-immutables-macro README](https://github.com/defi-wonderland/aztec-immutables-macro/tree/dev).
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Immutables via Salt
3+
sidebar_position: 4
4+
tags: [contracts, storage, immutables, optimization]
5+
description: Commit immutable values into a contract's address salt, eliminating initialization transactions.
6+
---
7+
8+
Aztec contracts can commit immutable values directly into the contract's address by encoding them into the deployment salt, removing the need for a separate initialization transaction.
9+
10+
## Overview
11+
12+
Rather than storing immutables in private storage (which requires an initializer function and an extra transaction), the [aztec-immutables-macro](https://github.com/defi-wonderland/aztec-immutables-macro/tree/dev) library encodes them into the contract's salt:
13+
14+
```
15+
salt = poseidon2_hash([actual_salt, constant_0, constant_1, ...])
16+
```
17+
18+
Since the salt is part of the address derivation, the immutable values become cryptographically bound to the contract's address itself.
19+
20+
## Key benefits
21+
22+
- **No initialization transaction** — immutables are committed at deployment time, not in a separate setup call
23+
- **Runtime verification** — at execution time, capsule data is loaded and verified against the stored salt, ensuring data integrity
24+
- **Persistent storage** — immutables are persisted to the PXE's [CapsuleStore](./advanced/how_to_use_capsules.md) after deployment, so capsules don't need to be attached to every transaction
25+
- **Compatible with standard storage** — works alongside `#[storage]` and initializers when needed
26+
27+
## Performance
28+
29+
Initialization cost is completely eliminated (no constructor transaction). The per-transaction overhead is approximately 1,098 gates (+0.2%) in the account entrypoint.
30+
31+
## Getting started
32+
33+
For installation instructions, usage examples, and a reference implementation of an initializerless Schnorr account contract, see the [aztec-immutables-macro README](https://github.com/defi-wonderland/aztec-immutables-macro/tree/dev).

0 commit comments

Comments
 (0)