use.miden::kernel_proc_offsets #! Returns the block number of the last known block at the time of transaction execution. #! #! Inputs: [] #! Outputs: [num] #! #! num is the last known block number. export.get_block_number # pad the stack padw padw padw push.0.0.0 # => [PAD(15)] exec.kernel_proc_offsets::get_block_number_offset # => [offset, PAD(15)] syscall.exec_kernel_proc # => [num, PAD(15)] # clean the stack swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [num] end #! Returns the block hash of the reference block. #! #! Stack: [EMPTY_WORD] #! Output: [BLOCK_HASH] #! #! Where: #! - BLOCK_HASH, reference block for the transaction execution. export.get_block_hash # pad the stack padw padw padw push.0.0.0 # => [PAD(15)] exec.kernel_proc_offsets::get_block_hash_offset # => [offset, PAD(15)] syscall.exec_kernel_proc # => [BLOCK_HASH, PAD(12)] # clean the stack swapdw dropw dropw swapw dropw # => [BLOCK_HASH] end #! Returns the input notes commitment hash. #! #! See `transaction::api::get_input_notes_commitment` for details. #! #! Stack: [] #! Outputs: [INPUT_NOTES_COMMITMENT] #! #! Where: #! - INPUT_NOTES_COMMITMENT is the input notes commitment hash. export.get_input_notes_commitment # pad the stack padw padw padw push.0.0.0 # => [PAD(15)] exec.kernel_proc_offsets::get_input_notes_commitment_offset # => [offset, PAD(15)] syscall.exec_kernel_proc # => [INPUT_NOTES_COMMITMENT, PAD(12)] # clean the stack swapdw dropw dropw swapw dropw # => [INPUT_NOTES_COMMITMENT] end #! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata) #! tuples over all output notes. #! #! Inputs: [0, 0, 0, 0] #! Outputs: [COM] #! #! COM is the output notes hash. export.get_output_notes_hash # pad the stack padw padw padw push.0.0.0 # => [PAD(15)] exec.kernel_proc_offsets::get_output_notes_hash_offset # => [offset, PAD(15)] syscall.exec_kernel_proc # => [COM, PAD(12)] # clean the stack swapdw dropw dropw swapw dropw # => [COM] end #! Creates a new note and returns the index of the note. #! #! Inputs: [tag, aux, note_type, execution_hint, RECIPIENT, ...] #! Outputs: [note_idx, ...] #! #! tag is the tag to be included in the note. #! aux is the auxiliary metadata to be included in the note. #! note_type is the storage type of the note #! execution_hint is the note's execution hint #! RECIPIENT is the recipient of the note. #! note_idx is the index of the crated note. export.create_note # pad the stack before the syscall to prevent accidental modification of the deeper stack # elements padw padw swapdw movup.8 drop # => [tag, aux, note_type, execution_hint, RECIPIENT, PAD(7)] exec.kernel_proc_offsets::create_note_offset # => [offset, tag, aux, note_type, execution_hint, RECIPIENT, PAD(7)] syscall.exec_kernel_proc # => [note_idx, PAD(15)] # remove excess PADs from the stack swapdw dropw dropw movdn.7 dropw drop drop drop # => [note_idx] end #! Adds the ASSET to the note specified by the index. #! #! Inputs: [ASSET, note_idx, ...] #! Outputs: [ASSET, note_idx, ...] #! #! note_idx is the index of the note to which the asset is added. #! ASSET can be a fungible or non-fungible asset. export.add_asset_to_note movup.4 exec.kernel_proc_offsets::add_asset_to_note_offset # => [offset, note_idx, ASSET] # pad the stack before the syscall to prevent accidental modification of the deeper stack # elements push.0.0 movdn.7 movdn.7 padw padw swapdw # => [offset, note_idx, ASSET, PAD(10)] syscall.exec_kernel_proc # => [note_idx, ASSET, PAD(11)] # remove excess PADs from the stack swapdw dropw dropw swapw movdn.7 drop drop drop movdn.4 # => [ASSET, note_idx] end #! Returns the RECIPIENT for a specified SERIAL_NUM, SCRIPT_HASH, and inputs hash #! #! Inputs: [SERIAL_NUM, SCRIPT_HASH, INPUT_HASH] #! Outputs: [RECIPIENT] #! export.build_recipient_hash padw hmerge # => [SERIAL_NUM_HASH, SCRIPT_HASH, INPUT_HASH] swapw hmerge # => [MERGE_SCRIPT, INPUT_HASH] swapw hmerge # [RECIPIENT] end #! Executes the provided procedure against the foreign account. #! #! WARNING: the procedure to be invoked can not have more than 15 inputs and it can not return more #! than 15 elements back. Otherwise exceeding elements will not be provided to the procedure and #! will not be returned from it. #! #! Inputs: [foreign_account_id, FOREIGN_PROC_ROOT, , pad(n), ...] #! Outputs: [] #! #! Where: #! - pad(n) is the exact number of pads needed to set the number of procedure inputs to 16 at the #! moment of the foreign procedure execution (n = 16 - mem_addr_size - foreign_inputs_len) export.execute_foreign_procedure.1 # pad the stack before the syscall push.0.0 movup.2 exec.kernel_proc_offsets::start_foreign_context_offset padw swapw padw padw swapdw # => [offset, foreign_account_id, pad(14), FOREIGN_PROC_ROOT, , pad(n), ...] # load the foreign account to the memory syscall.exec_kernel_proc # => [pad(16), FOREIGN_PROC_ROOT, , pad(n), ...] # prepare the stack for the dyncall dropw dropw dropw dropw # => [FOREIGN_PROC_ROOT, , pad(n), ...] # store the foreign procedure root to the first local memory slot and get its absolute memory # address loc_storew.0 dropw locaddr.0 # => [foreign_proc_root_ptr, , pad(n), ...] # execute the foreign procedure dyncall # => [] # reset the current account data offset to the native offset (2048) exec.kernel_proc_offsets::end_foreign_context_offset # => [offset, ] syscall.exec_kernel_proc # => [] end #! Updates the transaction expiration delta. #! #! The transaction expiration delta specifies how close to the transaction's reference block the #! transaction must be included into the chain. For example, if the transaction's reference block #! is 100 and transaction expiration delta is 10, the transaction can be included into the chain #! by block 110. If this does not happen, the transaction is considered expired and cannot be #! included into the chain. #! #! Once set, transaction expiration delta can be decreased, but not increased. #! #! Inputs: [block_height_delta, ...] #! Output: [...] #! #! Where: #! - block_height_delta is the desired expiration time delta (1 to 0xFFFF). export.update_expiration_block_delta exec.kernel_proc_offsets::update_expiration_block_num_offset # => [offset, expiration_delta, ...] # pad the stack push.0 movdn.2 push.0 movdn.2 padw swapw padw padw swapdw # => [offset, expiration_delta, PAD(14)] syscall.exec_kernel_proc # clear the stack dropw dropw dropw dropw end #! Returns the transaction expiration delta, or 0 if the delta has not been set. #! #! Inputs: [...] #! Output: [block_height_delta, ...] #! #! Where: #! - block_height_delta is the stored expiration time delta (1 to 0xFFFF). export.get_expiration_block_delta # pad the stack padw padw padw push.0.0.0 # => [PAD(15)] exec.kernel_proc_offsets::get_expiration_block_delta_offset # => [offset, PAD(15)] syscall.exec_kernel_proc # => [expiration_delta, PAD(15)] # clear the stack swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [expiration_delta] end