Skip to main content

create

Function create 

Source
pub fn create(tag: Tag, note_type: NoteType, recipient: Recipient) -> NoteIdx
Expand description

Creates a new output note and returns its index.

§Examples

Create a note and add a single asset to it:

// before using `Vec`/`vec!`.
extern crate alloc;

use miden::{felt, output_note, Asset, Digest, NoteType, Recipient, Tag, Word};

// Values used to derive the note recipient.
let serial_num = Word::from_u64_unchecked(1, 2, 3, 4);
let note_script_root = Digest::from_word(Word::from_u64_unchecked(0, 0, 0, 0));

// Note inputs are hashed via `hash_elements`.
let inputs = alloc::vec![felt!(0); 2];
let recipient = Recipient::compute(serial_num, note_script_root, inputs);

let tag = Tag::from(felt!(0));
let note_type = NoteType::from(felt!(1)); // public note type (0b01)

let note_idx = output_note::create(tag, note_type, recipient);
output_note::add_asset(Asset::new([felt!(0), felt!(0), felt!(0), felt!(1)]), note_idx);