diff --git a/docs/architecture/transactions/procedures.md b/docs/architecture/transactions/procedures.md index bde62bf0c..87f807e9c 100644 --- a/docs/architecture/transactions/procedures.md +++ b/docs/architecture/transactions/procedures.md @@ -8,73 +8,70 @@ There are user-facing procedures and kernel procedures. Users don't directly inv These procedures can be used to create smart contract/account code, note scripts, or account scripts. They basically serve as an API for the underlying kernel procedures. If a procedure can be called in the current context, an `exec` is sufficient. Otherwise the context procedures must be invoked by `call`. Users never need to invoke `syscall` procedures themselves. -!!! tip - - If capitalized, a variable representing a `word`, e.g., `ACCT_HASH` consists of four `felts`. If lowercase, the variable is represented by a single `felt`. +!!! tip - If capitalized, a variable representing a `word`, e.g., `ACCT_HASH` consists of four `felts`. If lowercase, the variable is represented by a single `felt`. ### Account -To import the account procedures, set `use.miden::account` at the beginning of the file. +To import the account procedures, set `use.miden::account` at the beginning of the file. Any procedure that changes the account state must be invoked in the account context and not by note or transaction scripts. All procedures invoke `syscall` to the kernel API and some are restricted by the kernel procedure `exec.authenticate_account_origin`, which fails if the parent context is not the executing account. -| Procedure name | Stack | Output | Context | Description | -|---------------------------|------------|--------------|---------|---------------------------------------------------------------------| -| `get_id` | `[]` | `[acct_id]` | account, note | | -| `get_nonce` | `[]` | `[nonce]` | account, note | | -| `get_initial_hash` | `[]` | `[H]` | account, note | | -| `get_current_hash` | `[]` | `[ACCT_HASH]`| account, note | -| `incr_nonce` | `[value]` | `[]` | account | | -| `get_item` | `[index]` | `[VALUE]` | account, note | | -| `set_item` | `[index, V']` | `[R', V]` | account | | -| `set_code` | `[CODE_ROOT]`| `[]` | account | | -| `get_balance` | `[faucet_id]`| `[balance]`| account, note | | -| `has_non_fungible_asset` | `[ASSET]` | `[has_asset]`| account, note | | -| `add_asset` | `[ASSET]` | `[ASSET']` | account | | -| `remove_asset` | `[ASSET]` | `[ASSET]` | account | | -| `get_vault_commitment` | `[]` | `[COM]` | account, note | | +| Procedure name | Stack | Output | Context | Description | +| ------------------------ | ------------------- | ------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `get_id` | `[]` | `[acct_id]` | account, note | | +| `get_nonce` | `[]` | `[nonce]` | account, note | | +| `get_initial_hash` | `[]` | `[H]` | account, note | | +| `get_current_hash` | `[]` | `[ACCT_HASH]` | account, note | | +| `incr_nonce` | `[value]` | `[]` | account | | +| `get_item` | `[index]` | `[VALUE]` | account, note | | +| `set_item` | `[index, V']` | `[R', V]` | account | | +| `set_code` | `[CODE_COMMITMENT]` | `[]` | account | | +| `get_balance` | `[faucet_id]` | `[balance]` | account, note | | +| `has_non_fungible_asset` | `[ASSET]` | `[has_asset]` | account, note | | +| `add_asset` | `[ASSET]` | `[ASSET']` | account | | +| `remove_asset` | `[ASSET]` | `[ASSET]` | account | | +| `get_vault_commitment` | `[]` | `[COM]` | account, note | | ### Note To import the note procedures, set `use.miden::note` at the beginning of the file. All procedures are restricted to the note context. -| Procedure name | Inputs | Outputs | Context | Description | -|--------------------------|---------------------|-----------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------| -| `get_assets` | `[dest_ptr]` | `[num_assets, dest_ptr]` | note | | -| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | | -| `get_sender` | `[]` | `[sender]` | note | | -| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | | - +| Procedure name | Inputs | Outputs | Context | Description | +| --------------------- | -------------------------- | ------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `get_assets` | `[dest_ptr]` | `[num_assets, dest_ptr]` | note | | +| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | | +| `get_sender` | `[]` | `[sender]` | note | | +| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | | ### Tx -To import the transaction procedures set `use.miden::tx` at the beginning of the file. Only the `create_note` procedure is restricted to the account context. -| Procedure name | Inputs | Outputs | Context | Description | -|--------------------------|------------------|-------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `get_block_number` | `[]` | `[num]` | account, note |