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
#[aztec(note)]
struct AddressNote {
address: AztecAddress,
// The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent.
npk_m_hash: Field,
randomness: Field,
}
Source code: noir-projects/aztec-nr/address-note/src/address_note.nr#L15-L24

Importing AddressNote

In Nargo.toml

address_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.55.1", 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#L9-L11

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_keys.npk_m.hash());
Source code: noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr#L25-L27

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

Learn more