use.miden::account use.miden::tx # CONSTANTS # ================================================================================================= const.PUBLIC_NOTE=1 #! Adds the provided asset to the current account. #! #! Inputs: [ASSET] #! Outputs: [0, 0, 0, 0, ...] #! #! - ASSET is the asset to be received, can be fungible or non-fungible #! #! FAILS if: #! - The same non-fungible asset already exists in the account. #! - Adding a fungible asset would result in amount overflow, i.e., #! the total amount would be greater than 2^63. export.receive_asset exec.account::add_asset padw swapw dropw end #! Creates a new note. #! #! The created note will not have any assets attached to it. To add assets to this note use the #! `move_asset_to_note` procedure. #! #! This procedure is expected to be invoked using a `call` instruction. It makes no guarantees about #! the contents of the `PAD` elements shown below. It is the caller's responsibility to make sure #! these elements do not contain any meaningful data. #! #! Inputs: [tag, aux, note_type, execution_hint, RECIPIENT, PAD(8)] #! Outputs: [note_idx, PAD(15)] #! #! - tag is the tag to be included in the note. #! - aux is the auxiliary data to be included in the note. #! - note_type is the note's storage type #! - execution_hint is the note's execution hint #! - RECIPIENT is the recipient of the note, i.e., #! hash(hash(hash(serial_num, [0; 4]), script_hash), input_hash) export.create_note exec.tx::create_note # => [note_idx, PAD(15) ...] end #! Removes the specified asset from the account and adds it to the output note with the specified #! index. #! #! This procedure is expected to be invoked using a `call` instruction. It makes no guarantees about #! the contents of the `PAD` elements shown below. It is the caller's responsibility to make sure #! these elements do not contain any meaningful data. #! #! Inputs: [ASSET, note_idx, PAD(11)] #! Outputs: [ASSET, note_idx, PAD(11)] #! #! - note_idx is the index of the output note. #! - ASSET is the fungible or non-fungible asset of interest. #! #! Panics: #! - The fungible asset is not found in the vault. #! - The amount of the fungible asset in the vault is less than the amount to be removed. #! - The non-fungible asset is not found in the vault. export.move_asset_to_note # remove the asset from the account exec.account::remove_asset # => [ASSET, note_idx, PAD(11)] exec.tx::add_asset_to_note # => [ASSET, note_idx, PAD(11) ...] end