Expand description
Contains the Client APIs related to notes. Notes can contain assets and scripts that are executed as part of transactions.
This module enables the tracking, retrieval, and processing of notes. It offers methods to query input and output notes from the store, check their consumability, compile note scripts, and retrieve notes based on partial ID matching.
§Overview
The module exposes APIs to:
- Retrieve input notes and output notes.
- Determine the consumability of notes using the
NoteScreener. - Compile note scripts from source code with
compile_note_script. - Retrieve an input note by a prefix of its ID using the helper function
get_input_note_with_id_prefix.
§Example
use miden_client::{
auth::TransactionAuthenticator,
Client,
crypto::FeltRng,
note::{NoteScreener, get_input_note_with_id_prefix},
store::NoteFilter,
};
use miden_protocol::account::AccountId;
// Retrieve all committed input notes
let input_notes = client.get_input_notes(NoteFilter::Committed).await?;
println!("Found {} committed input notes.", input_notes.len());
// Check consumability for a specific note
if let Some(note) = input_notes.first() {
let consumability = client.get_note_consumability(note.clone()).await?;
println!("Note consumability: {:?}", consumability);
}
// Retrieve an input note by a partial ID match
let note_prefix = "0x70b7ec";
match get_input_note_with_id_prefix(client, note_prefix).await {
Ok(note) => println!(
"Found note with matching prefix: {}",
note.id().expect("note matched by ID prefix has an ID").to_hex()
),
Err(err) => println!("Error retrieving note: {err:?}"),
}
// Compile the note script
let script_src = "@note_script\npub proc main\n push.9 push.12 add\nend";
let note_script = client.code_builder().compile_note_script(script_src)?;
println!("Compiled note script successfully.");
For more details on the API and error handling, see the documentation for the specific functions and types in this module.
Modules§
- standards
- Raw access to
miden-standardsnote modules for items not curated bymiden-client.
Structs§
- Block
Number - A convenience wrapper around a
u32representing the number of a block. - Failed
Note - Represents a failed note consumption.
- Input
Note Reader - A lazy iterator over consumed input notes for a specific consumer account.
- Input
Note Update - Represents the possible states of an input note record in a
NoteUpdateTracker. - Mint
Note - TODO: add docs
- Network
Account Target - A
NoteAttachmentfor notes targeted at network accounts. - Note
- A note with all the data required for it to be consumed by executing it against the transaction kernel.
- Note
Assets - An asset container for a note.
- Note
Attachment - The optional attachment for a
Note. - Note
Attachment Content - The content of a
NoteAttachment. - Note
Attachment Header - The header metadata for a single note attachment.
- Note
Attachment Scheme - The user-defined scheme of a
NoteAttachment. - Note
Attachments - A collection of note attachments.
- Note
Consumption - A note consumption event observed on chain.
- Note
Consumption Info - Contains information about the successful and failed consumption of notes.
- Note
Details - Details of a note consisting of assets, script, storage, and a serial number.
- Note
Details Commitment - A commitment to a note’s details, without note metadata.
- Note
Header - Holds the strictly required, public information of a note.
- NoteId
- The unique identifier of a note.
- Note
Inclusion Proof - Contains the data required to prove inclusion of a note in the canonical chain.
- Note
Location - Contains information about the location of a note.
- Note
Metadata - Protocol-level note metadata that combines
PartialNoteMetadatawith attachment information. - Note
Recipient - Value that describes under which condition a note can be consumed.
- Note
Screener - Provides functionality for testing whether a note is relevant to the client or not.
- Note
Script - An executable program of a note.
- Note
Script Root - The MAST root of a
NoteScript. - Note
Storage - A container for note storage items.
- NoteTag
NoteTags are 32-bits of data that serve as best-effort filters for notes.- Note
Update Tracker - Contains note changes to apply to the store.
- Nullifier
- A note’s nullifier.
- Output
Note Update - Represents the possible states of an output note record in a
NoteUpdateTracker. - P2id
Note - TODO: add docs
- P2id
Note Storage - Canonical storage representation for a P2ID note.
- P2ide
Note - Pay-to-ID Extended (P2IDE) note abstraction.
- P2ide
Note Storage - Canonical storage representation for a P2IDE note.
- Partial
Note - A note without detailed recipient information.
- Partial
Note Metadata - The user-facing metadata associated with a note.
- Pswap
Note - A partially-fillable swap note for decentralized asset exchange.
- Swap
Note - TODO: add docs
Enums§
- Mint
Note Storage - Represents the different storage formats for MINT notes.
- Note
Consumption Status - Describes if a note could be consumed under a specific conditions: target account state and block height.
- Note
Error - Note
Execution Hint - Specifies the conditions under which a note is ready to be consumed. These conditions are meant to be encoded in the note script as well.
- Note
File - A serialized representation of a note.
- Note
Screener Error - Error when screening notes to check relevance to a client.
- Note
Type - Note
Update Type - Represents the possible types of updates that can be applied to a note in a
NoteUpdateTracker. - Standard
Note - The enum holding the types of standard notes provided by
miden-standards.
Traits§
- ToInput
Note Commitments - Specifies the data used by the transaction kernel to commit to a note.
Functions§
- get_
input_ note_ with_ id_ prefix - Returns the client input note whose ID starts with
note_id_prefix.
Type Aliases§
- Note
Consumability - Represents the consumability of a note by a specific account.