The tx Module
A Miden transaction consumes zero or more input notes and produces state changes plus output notes for a single account. A client or network transaction builder executes the code and proves the result. Submission includes the proof, sealed inputs, and public state updates. The tx module provides access to block information, note commitments, and expiration controls. Transaction scripts (#[tx_script]) serve as standalone entry points that orchestrate the transaction.
The tx module
use miden::{BlockNumber, Word, tx};
Block information
// Transaction reference block number
let block_num: BlockNumber = tx::get_reference_block_number();
// Reference block commitment (hash of block header)
let commitment: Word = tx::get_reference_block_commitment();
// Reference block timestamp (seconds since epoch)
let timestamp: u32 = tx::get_block_timestamp();
Note commitments
// Commitment over all input notes in this transaction
let input_commit: Word = tx::get_input_notes_commitment();
// Commitment over all output notes in this transaction
let output_commit: Word = tx::get_output_notes_commitment();
// Number of input/output notes
let num_inputs: u32 = tx::get_num_input_notes();
let num_outputs: u32 = tx::get_num_output_notes();
Transaction expiration
Control how long a transaction remains valid:
// Get current expiration delta (in blocks)
let delta: u16 = tx::get_expiration_block_delta();
// Set a new expiration delta
tx::update_expiration_block_delta(100);
The expiration delta is measured from the transaction's reference block. A value of 0 means no expiration has been set; updates must be between 1 and u16::MAX and can only tighten an existing expiration limit. Creating a network note or invoking a token transfer policy tightens the limit to at most 20 blocks.
Transaction scripts
Transaction scripts use the #[tx_script] macro to define a top-level entry point for the transaction. See Transaction Scripts for the full #[tx_script] API and examples.
For signature verification using the transaction context, see Authentication. For time-based patterns using tx::get_reference_block_number(), see Patterns — Rate limiting.
Full API docs on docs.rs: miden::tx