Merge

Create a merge transaction

With the merge function, it is possible to combine two STAS UTXO inputs into one output. However, please keep in mind that this function can only be used by tokens that have the splittable property set to true. For more information on which token templates have this property, please see Token Properties.

The merge function has different parameters compared to the split or transfer functions. It necessitates the previous transaction hex value of the UTXOs being merged, and the required format is as follows:

const stasInput1 = {
    txHex : 'previous transaction hex string',
    vout : 'output index of the UTXO being spent'
}

const stasInput2 = {
    txHex : 'previous transaction hex string',
    vout : 'output index of the UTXO being spent'
}

The previous transaction hex is required as part of the unlocking script to complete the merge functionality. To create a merge transaction, the following additional parameters are necessary: private keys for both UTXO inputs, a destination address, and the payment UTXO and its corresponding private key.

const mergeHex = await stasMerge.signed(
    ownerPrivateKey1,
    stasInput1,
    ownerPrivateKey2,
    stasInput2,
    destinationAddr,
    paymentPrivateKey,
    paymentUtxo
)

The MergeSplit function works in a similar way to merge, with the exception that instead of a single destination address, it accepts an array of splitDestinations, just like in the split function.

Last updated