Skip to main content

Using Address Note in Aztec.nr

Address notes hold one main property of the type AztecAddress. It also holds npk_m_hash and randomness, similar to other note types.

AddressNote

This is the AddressNote struct:

address_note_struct
// Stores an address
#[note]
#[derive(Serialize)]
pub struct AddressNote {
address: AztecAddress,
owner: AztecAddress,
randomness: Field,
}
Source code: noir-projects/aztec-nr/address-note/src/address_note.nr#L17-L26

Importing AddressNote

In Nargo.toml

address_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.66.0", directory="noir-projects/aztec-nr/address-note" }

In your contract

addressnote_import
use dep::address_note::address_note::AddressNote;
Source code: noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr#L13-L15

Working with AddressNote

Creating a new note

Creating a new AddressNote takes the following args:

  • address (AztecAddress): the address to store in the AddressNote
  • npk_m_hash (Field): the master nullifier public key hash of the user
addressnote_new
let mut note = AddressNote::new(owner, owner);
Source code: noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr#L27-L29

In this example, owner is the address and the npk_m_hash of the donor was computed earlier.

Learn more