Struct miden_objects::notes::Note
source · pub struct Note { /* private fields */ }Expand description
A note with all the data required for it to be consumed by executing it against the transaction kernel.
Notes are created with a script, inputs, assets, and a serial number. Fungible and non-fungible asset transfers are done by moving assets to the note’s assets. The note’s script determines the conditions required for the note consumpution, i.e. the target account of a P2ID or conditions of a SWAP, and the effects of the note. The serial number has a double duty of preventing double spend, and providing unlikability to the consumer of a note. The note’s inputs allow for customization of its script.
To create a note, the kernel does not require all the information above, a user can create a note only with the commitment to the script, inputs, the serial number, and the kernel only verifies the source account has the assets necessary for the note creation. See NoteRecipient for more details.
Implementations§
source§impl Note
impl Note
sourcepub fn new(
assets: NoteAssets,
metadata: NoteMetadata,
recipient: NoteRecipient
) -> Self
pub fn new( assets: NoteAssets, metadata: NoteMetadata, recipient: NoteRecipient ) -> Self
Returns a new note created with the specified parameters.
sourcepub fn assets(&self) -> &NoteAssets
pub fn assets(&self) -> &NoteAssets
Returns the note’s assets.
sourcepub fn metadata(&self) -> &NoteMetadata
pub fn metadata(&self) -> &NoteMetadata
Returns the note’s metadata.
sourcepub fn recipient(&self) -> &NoteRecipient
pub fn recipient(&self) -> &NoteRecipient
Returns the note’s recipient.
sourcepub fn id(&self) -> NoteId
pub fn id(&self) -> NoteId
Returns the note’s unique identifier.
This value is both an unique identifier and a commitment to the note.
sourcepub fn authentication_hash(&self) -> Digest
pub fn authentication_hash(&self) -> Digest
Returns the note’s authentication hash.
This value is used authenticate the note’s presence in the note tree, it is computed as:
hash(note_id, note_metadata)
sourcepub fn nullifier(&self) -> Nullifier
pub fn nullifier(&self) -> Nullifier
Returns the note’s nullifier.
This is public data, used to prevent double spend.
sourcepub fn serial_num(&self) -> Word
pub fn serial_num(&self) -> Word
Returns the note’s recipient serial_num, the secret required to consume the note.
sourcepub fn script(&self) -> &NoteScript
pub fn script(&self) -> &NoteScript
Returns the note’s recipient script which locks the assets of this note.
sourcepub fn inputs(&self) -> &NoteInputs
pub fn inputs(&self) -> &NoteInputs
Returns the note’s recipient inputs which customizes the script’s behavior.
sourcepub fn recipient_digest(&self) -> Digest
pub fn recipient_digest(&self) -> Digest
Returns the note’s recipient digest, which commits to its details.
This is the public data required to create a note.
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 NoteEnvelope
impl From<Note> for NoteEnvelope
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.