Generator

The Transaction Generator simplifies the transaction creation process by:

  • Dynamically calculating transaction mass.
  • Accounting for custom transaction Fee Rates.
  • Automatically creating daisy-chained (batch/sweep) transactions if your UTXO set exceeds the maximum mass allowed in a single transaction.
  • Calculating the correct transaction change output.

The Transaction Generator functions as an iterator, producing a PendingTransaction object that can be submitted to the Kaspa network. A PendingTransaction wraps a regular Transaction and provides additional metadata, such as:

  • A list of UTXO entries (required for transaction signing).
  • A reference to the originating UtxoContext (useful for distinguishing regular outbound transactions from inter-account transfers).

Upon completion, the Generator::summary() function can be used to generate a GeneratorSummary object. This summary provides cumulative information about the transaction generation process, including the total transaction mass, which can be useful for calculating transaction fees.

References

WASM SDK

Rust SDK