Expand description
Unified transaction representation for SNARK circuits
This module provides a single, unified structure (TransactionUnion) that
can represent all transaction types (payments, stake delegations, fee
transfers, coinbase) for SNARK circuit processing. This enables efficient
proof generation by using a single circuit design regardless of the specific
transaction type.
§Transaction Union
The TransactionUnion type encodes all transaction variants using a
tagged union approach:
Common: Fields present in all transactions (fee, nonce, memo, etc.)Body: Transaction-specific fields with interpretation based onTagTag: Discriminates between Payment, StakeDelegation, FeeTransfer, and Coinbase
§Field Interpretation
Fields in Body are interpreted differently based on the Tag value:
- Payment:
source_pkandreceiver_pkare sender and recipient - Stake Delegation:
receiver_pkis the new delegate - Fee Transfer:
receiver_pkis the fee recipient,amountis the fee - Coinbase:
receiver_pkis the block producer,amountis the reward
§Receipt Chain Hash
This module also provides functions for computing receipt chain hashes, which commit to the sequence of transactions applied to an account:
cons_signed_command_payload: Updates receipt chain hash for signed commandscons_zkapp_command_commitment: Updates receipt chain hash for zkApp commandschecked_cons_signed_command_payload: Checked version for use in circuits
§Timing and Vesting
The module implements timing validation for timed (vested) accounts:
validate_timing: Ensures timing constraints are met for an account deductionvalidate_nonces: Validates transaction nonce matches account nonceaccount_check_timing: Checks timing status for an accounttiming_error_to_user_command_status: Converts timing errors to transaction failures
Timed accounts have a minimum balance that decreases over time according to a vesting schedule. When the minimum balance reaches zero, the account automatically becomes untimed.
§Account Helpers
Utility functions for account operations:
get_with_location: Retrieves an account or creates a placeholder for new accountsExistingOrNew: Indicates whether an account exists or is newly createdadd_amount/sub_amount: Safe balance arithmetic with overflow/underflow checking
Structs§
Enums§
Functions§
- account_
check_ timing - add_
amount - checked_
cons_ signed_ command_ payload - Returns the new
receipt_chain_hash - cons_
signed_ command_ payload - Returns the new
receipt_chain_hash - cons_
zkapp_ command_ commitment - prepend account_update index computed by Zkapp_command_logic.apply
- get_
account - get_
with_ location - set_
account - sub_
amount - timing_
error_ to_ user_ command_ status - validate_
nonces - validate_
timing - validate_
timing_ 🔒with_ min_ balance - validate_
timing_ 🔒with_ min_ balance_ impl