Skip to content

Commit

Permalink
chore: add procedures to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyrd committed Nov 29, 2024
1 parent 67a3151 commit c4b431e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions docs/architecture/transactions/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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`.
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

Expand Down Expand Up @@ -37,24 +37,26 @@ Any procedure that changes the account state must be invoked in the account cont

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 | <ul> <li>Writes the assets of the currently executing note into memory starting at the specified address `dest_ptr `. </li><li> `num_assets` is the number of assets in the currently executing note.</li> </ul> |
| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | <ul> <li>Writes the inputs of the currently executed note into memory starting at the specified address, `dest_ptr`. </li> </ul> |
| `get_sender` | `[]` | `[sender]` | note | <ul> <li>Returns the `sender` of the note currently being processed. Panics if a note is not being processed. </li> </ul> |
| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | <ul> <li>Computes hash of note inputs starting at the specified memory address.</li> </ul> |
| Procedure name | Inputs | Outputs | Context | Description |
| ------------------------ | -------------------------- | ------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `get_assets` | `[dest_ptr]` | `[num_assets, dest_ptr]` | note | <ul> <li>Writes the assets of the currently executing note into memory starting at the specified address `dest_ptr `. </li><li> `num_assets` is the number of assets in the currently executing note.</li> </ul> |
| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | <ul> <li>Writes the inputs of the currently executed note into memory starting at the specified address, `dest_ptr`. </li> </ul> |
| `get_sender` | `[]` | `[sender]` | note | <ul> <li>Returns the `sender` of the note currently being processed. Panics if a note is not being processed. </li> </ul> |
| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | <ul> <li>Computes hash of note inputs starting at the specified memory address.</li> </ul> |
| `get_note_serial_number` | `[]` | `[SERIAL_NUMBER]` | note | <ul> <li>Returns the serial number of the note currently being processed.</li> </ul> |
| `get_script_hash` | `[]` | `[SCRIPT_HASH]` | note | <ul> <li>Returns the script hash of the note currently being processed.</li> </ul> |

### 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 | <ul> <li>Returns the block number `num` of the last known block at the time of transaction execution. |
| `get_block_hash` | `[]` | `[H]` | account, note | <ul> <li>Returns the block hash `H` of the last known block at the time of transaction execution.</li> </ul> |
| Procedure name | Inputs | Outputs | Context | Description |
| ----------------------------- | ------------------------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `get_block_number` | `[]` | `[num]` | account, note | <ul> <li>Returns the block number `num` of the last known block at the time of transaction execution. |
| `get_block_hash` | `[]` | `[H]` | account, note | <ul> <li>Returns the block hash `H` of the last known block at the time of transaction execution.</li> </ul> |
| `get_input_notes_commitment` | `[]` | `[COM]` | account, note | <ul> <li>Returns the input notes hash `COM`. </li><li>This is computed as a sequential hash of (nullifier, empty_word_or_note_hash) tuples over all input notes. The `empty_word_or_notes_hash` functions as a flag, if the value is set to zero, then the notes are authenticated by the transaction kernel. If the value is non-zero, then note authentication will be delayed to the batch/block kernel. The delayed authentication allows a transaction to consume a public note that is not yet included to a block. </li> </ul> |
| `get_output_notes_commitment` | `[0, 0, 0, 0]` | `[COM]` | account, note | <ul> <li>Returns the output notes hash `COM`. </li><li>This is computed as a sequential hash of (note_id, note_metadata) tuples over all output notes. </li> </ul> |
| `create_note` | `[ASSET, tag, RECIPIENT]` | `[ptr]` | account | <ul> <li>Creates a new note and returns a pointer to the memory address at which the note is stored.</li><li> `ASSET` is the asset to be included in the note. </li><li>`tag` is the tag to be included in the note. `RECIPIENT` is the recipient of the note.</li><li> `ptr` is the pointer to the memory address at which the note is stored.</li> </ul> |
| `create_note` | `[ASSET, tag, RECIPIENT]` | `[ptr]` | account | <ul> <li>Creates a new note and returns a pointer to the memory address at which the note is stored.</li><li> `ASSET` is the asset to be included in the note. </li><li>`tag` is the tag to be included in the note. `RECIPIENT` is the recipient of the note.</li><li> `ptr` is the pointer to the memory address at which the note is stored.</li> </ul> |

### Asset

Expand Down

0 comments on commit c4b431e

Please sign in to comment.