-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): Note type IDs and compute_note_hash_and_nullifier page (#…
…4636) Closes https://github.com/orgs/AztecProtocol/projects/11/views/23?pane=issue&itemId=52988548 --------- Co-authored-by: josh crites <[email protected]>
- Loading branch information
1 parent
0ab0a94
commit 032874a
Showing
7 changed files
with
107 additions
and
458 deletions.
There are no files selected for viewing
474 changes: 57 additions & 417 deletions
474
docs/docs/developers/contracts/references/storage/main.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...lopers/contracts/writing_contracts/functions/compute_note_hash_and_nullifier.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: How to define compute_note_hash_and_nullifier | ||
--- | ||
|
||
Aztec will automatically compute and manage notes and nullifiers that are created in smart contracts. However, in some cases, it might make sense to write custom logic for how these are computed. This is achieved through the `compute_note_hash_and_nullifier()` function, which tells the [PXE](../../../../learn/concepts/pxe/main.md) how to handle notes in your smart contract. | ||
|
||
## Params and returns | ||
|
||
The function should take 5 parameters: | ||
|
||
* Contract address | ||
* Nonce | ||
* Storage slot | ||
* Note type ID | ||
* Serialiazed note | ||
|
||
It should return `pub [Field; 4]` which is an array of 4 elements that tells the PXE how to handle the notes and nullifiers: | ||
|
||
#include_code compute_note_hash_and_nullifier_returns noir-projects/aztec-nr/aztec/src/note/utils.nr rust | ||
|
||
## Placeholder | ||
|
||
If you don't have any private state variables defined, you can use this placeholder function: | ||
|
||
#include_code compute_note_hash_and_nullifier_placeholder /noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr rust | ||
|
||
## When using notes | ||
|
||
If you are using custom notes or note types that come with Aztec.nr, you can call the util function `compute_note_hash_and_nulilfier` from the `aztec::utils` library in Aztec.nr. This will return the array needed. | ||
|
||
This function takes: | ||
|
||
#include_code compute_note_hash_and_nullifier_args /noir-projects/aztec-nr/aztec/src/note/utils.nr rust | ||
|
||
Here is an example from the [token contract](../../../tutorials/writing_token_contract.md): | ||
|
||
#include_code compute_note_hash_and_nullifier /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters