Generator is a type capable of generating transactions based on a supplied set of UTXO entries or a UTXO entry producer (such as UtxoContext). The Generator accumulates UTXO entries until it can generate a transaction that meets the requested amount or until the total mass of created inputs exceeds the allowed transaction mass, at which point it will produce a compound transaction by forwarding all selected UTXO entries to the supplied change address and prepare to start generating a new transaction. Such sequence of daisy-chained transactions is known as a "batch". Each compound transaction results in a new UTXO, which is immediately reused in the subsequent transaction.

The Generator constructor accepts a single IGeneratorSettingsObject object.


let generator = new Generator({
utxoEntries : [...],
changeAddress : "kaspa:...",
outputs : [
{ amount : kaspaToSompi(10.0), address: "kaspa:..."},
{ amount : kaspaToSompi(20.0), address: "kaspa:..."},
...
],
priorityFee : 1000n,
});

let pendingTransaction;
while(pendingTransaction = await generator.next()) {
await pendingTransaction.sign(privateKeys);
await pendingTransaction.submit(rpc);
}

let summary = generator.summary();
console.log(summary);

Constructors

Methods

Constructors

Methods

  • Returns void

  • Generate next transaction

    Returns Promise<any>

Generated using TypeDoc