Transaction Chaining
Problem Statement
Transaction chaining is a method with a purpose to address concurrency challenges inherent to Cardano’s eUTXO model by offering a decentralized alternative to the restrictive batching processes
Solution
Transaction chaining sorts UTXOs on a “first-come-first-served” basis, enabling quicker transaction processing without off-chain batching. This method ensures that transactions not confirmed on-chain are simply reversed, preventing fund loss and improving throughput.
In this process, transactions enter the mempool for validation. Each transaction is tied to a specific UTXO state; changes in this state prevent transaction execution unless the original UTXO is present. This ensures that transactions are processed in the order they are received.
Implementation in Lucid Evolution
const [newWalletInputs, derivedOutputs, tx] = await user
.newTx()
.pay.ToAddressWithData(
contractAddress,
{
kind: "inline",
value: datum,
},
{ lovelace: 10_000_000n }
)
.chain();
const signed = await tx.sign.withWallet().complete();
const txHash = await signed.submit();
Components
-
newWalletInputs
: This includes all UTXOs that were not spent in the transaction and the new wallet UTXOs derived from the output transaction -
derivedOutputs
: The derived outputs extracted from the completed transaction -
tx
: The new transaction that is ready to be submitted
Fresh set of UTXOs
To construct a new transaction using tx chaining, the UTXOs belonging to the wallet must be overridden. This is necessary because these UTXOs are not yet recorded on the blockchain.
user.overrideUTxOs(newWalletInputs);
This function updates the wallet's UTXOs to set the new ones, ensuring the next transaction chaining can be constructed correctly.