Struct miden_objects::notes::Note
source · pub struct Note { /* private fields */ }Expand description
A note which can be used to transfer assets between accounts.
This struct is a full description of a note which is needed to execute a note in a transaction. A note consists of:
Core on-chain data which is used to execute a note:
- A script which must be executed in a context of some account to claim the assets.
- A set of inputs which can be read to memory during script execution via the invocation of the
note::get_inputsin the kernel API. - A set of assets stored in the note.
- A serial number which can be used to break linkability between note hash and note nullifier.
Auxiliary data which is used to verify authenticity and signal additional information:
- A metadata object which contains information about the sender, the tag and the number of assets in the note.
Implementations§
source§impl Note
impl Note
sourcepub fn new(
script: NoteScript,
inputs: &[Felt],
assets: &[Asset],
serial_num: Word,
sender: AccountId,
tag: Felt
) -> Result<Self, NoteError>
pub fn new( script: NoteScript, inputs: &[Felt], assets: &[Asset], serial_num: Word, sender: AccountId, tag: Felt ) -> Result<Self, NoteError>
Returns a new note created with the specified parameters.
§Errors
Returns an error if:
- The number of inputs exceeds 16.
- The number of provided assets exceeds 1000.
- The list of assets contains duplicates.
sourcepub fn from_parts(
script: NoteScript,
inputs: NoteInputs,
assets: NoteAssets,
serial_num: Word,
metadata: NoteMetadata
) -> Self
pub fn from_parts( script: NoteScript, inputs: NoteInputs, assets: NoteAssets, serial_num: Word, metadata: NoteMetadata ) -> Self
Returns a note instance created from the provided parts.
sourcepub fn script(&self) -> &NoteScript
pub fn script(&self) -> &NoteScript
Returns a reference script which locks the assets of this note.
sourcepub fn inputs(&self) -> &NoteInputs
pub fn inputs(&self) -> &NoteInputs
Returns a reference to the note inputs.
sourcepub fn assets(&self) -> &NoteAssets
pub fn assets(&self) -> &NoteAssets
Returns a reference to the asset of this note.
sourcepub fn serial_num(&self) -> Word
pub fn serial_num(&self) -> Word
Returns a serial number of this note.
sourcepub fn metadata(&self) -> &NoteMetadata
pub fn metadata(&self) -> &NoteMetadata
Returns the metadata associated with this note.
sourcepub fn recipient(&self) -> Digest
pub fn recipient(&self) -> Digest
Returns the recipient of this note.
Recipient is defined and calculated as:
hash(hash(hash(serial_num, [0; 4]), script_hash), input_hash)
sourcepub fn id(&self) -> NoteId
pub fn id(&self) -> NoteId
Returns a unique identifier of this note, which is simultaneously a commitment to the note.
sourcepub fn authentication_hash(&self) -> Digest
pub fn authentication_hash(&self) -> Digest
Returns the value used to authenticate a notes existence in the note tree. This is computed as a 2-to-1 hash of the note hash and note metadata [hash(note_id, note_metadata)]
Trait Implementations§
source§impl Deserializable for Note
impl Deserializable for Note
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl From<&Note> for NoteEnvelope
impl From<&Note> for NoteEnvelope
source§impl From<&Note> for OutputNote
impl From<&Note> for OutputNote
source§impl From<Note> for NoteEnvelope
impl From<Note> for NoteEnvelope
source§impl From<Note> for OutputNote
impl From<Note> for OutputNote
source§impl PartialEq for Note
impl PartialEq for Note
source§impl Serializable for Note
impl Serializable for Note
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.