Blockchain

Transaction Chains: How a Transaction Spends a Freshly Created UTXO

To truly grasp the Bitcoin white paper's definition of a coin as a chain of digital signatures, you must understand transaction chains. This article starts from the simplest model to explain how UTXOs transfer between transactions and why transaction chains are essential for state management in BSV applications.

Ethan Lin

Ethan Lin

technical_editor

Published Jun 18, 20264 min read

Key Takeaway

A transaction chain describes the continuous process of UTXOs being spent and re-created across a series of transactions. Understanding this concept unlocks the meaning of the white paper statement that a coin is a chain of digital signatures, and shows why many BSV applications carry state forward by updating UTXOs in sequence.

Transaction Chains: How a Transaction Spends a Freshly Created UTXO article cover

A Minimal Model: From A to B

Suppose Transaction A creates an output:

TEXT
1Transaction A
2 output 0: 1000 satoshis, locked to Alice

At this point, output 0 is still a UTXO.

Transaction B wants to spend it, so it must reference:

TEXT
1Transaction A's txid + output index 0

Transaction B's input:

TEXT
1Transaction B
2 input 0: references A:0, provides Alice's signature and public key

Transaction B then creates new outputs:

TEXT
1Transaction B
2 output 0: 600 satoshis, locked to Bob
3 output 1: 350 satoshis, change back to Alice
4 fee: 50 satoshis

Now, A's output 0 has been spent and is no longer a UTXO. B's output 0 and output 1 become new UTXOs.

Why It's Called a Chain

Each subsequent transaction references an output from a previous transaction.

TEXT
1Coinbase or earlier transaction
2 -> Transaction A output 0
3 -> Transaction B input 0 spends A:0, creates B:0
4 -> Transaction C input 0 spends B:0, creates C:0

This is the chain of a coin. It's not an account balance table but a history of outputs being spent and re-created.

Note: The blockchain is a chain of blocks linked by time and proof-of-work; the UTXO chain is the chain of coin ownership transferring across transactions. Together, they form the traceable public ledger.

Building a Transaction Chain with the SDK

Key to constructing a transaction chain manually: Transaction B’s input must reference Transaction A’s output.

Below is a conceptual code example using the BSV TypeScript SDK:

TypeScript
1const txA = new Transaction()
2
3txA.addInput({
4 sourceTransaction: fundingTx,
5 sourceOutputIndex: 0,
6 unlockingScriptTemplate: new P2PKH().unlock(alicePrivateKey)
7})
8
9txA.addOutput({
10 lockingScript: new P2PKH().lock(aliceAddress),
11 satoshis: 500
12})
13
14txA.addOutput({
15 lockingScript: new P2PKH().lock(aliceAddress),
16 change: true
17})
18
19await txA.fee()
20await txA.sign()
21
22const txB = new Transaction()
23
24txB.addInput({
25 sourceTransaction: txA,
26 sourceOutputIndex: 0,
27 unlockingScriptTemplate: new P2PKH().unlock(alicePrivateKey)
28})
29
30txB.addOutput({
31 lockingScript: new P2PKH().lock(bobAddress),
32 satoshis: 300
33})
34
35txB.addOutput({
36 lockingScript: new P2PKH().lock(aliceAddress),
37 change: true
38})
39
40await txB.fee()
41await txB.sign()

Note: In real-world broadcast scenarios, you must also handle the order of txA and txB, dependency relationships, fees, service policies, and error handling.

Unconfirmed Transactions Can Form Dependencies

Transaction B can directly depend on an output from Transaction A, even if A hasn't been accepted by the network or included in a block yet. In this case, txB depends on a parent transaction that is still unstable.

This dependency is significant in practice:

  • txB depends on txA.
  • If txA is invalid, txB cannot be valid.
  • If txA hasn't propagated to a processing node, txB may fail due to a missing parent.

The official Advanced Transaction Tutorial describes options like sendWith that allow dependent transactions to be sent together. Production systems need to handle parent-child relationships, ancestor limits, retries, and state queries.

Transaction Chains and Application State

BSV applications can model state as a chain of UTXOs. For example:

  • A token can be represented by a single UTXO. When the token is transferred, the old token UTXO is spent and a new token UTXO is created.
  • A credential's state can be updated through a transaction chain: the old state output is spent, and a new state output records the updated state.
  • Games, orders, or supply chain events can follow a similar pattern, recording state changes in successive transactions.

This design has the advantage that state transitions have a clear predecessor-successor relationship—each step references the previous state—rather than allowing arbitrary row writes like a traditional database.

Transaction Chains and Parallel Processing

The UTXO model also offers inherent parallelism benefits:

  • If two transactions spend different UTXOs, they have no direct conflict and can be processed in parallel.
  • If two transactions spend the same UTXO, they conflict and only one can be valid.

This is crucial for BSV scaling. Large numbers of independent UTXOs can be verified and processed concurrently, avoiding the bottleneck of a single global account state.

Why Wallets Must Manage UTXOs

Transaction chains also explain why wallets can't just keep a single balance figure. They must track:

  • Which UTXOs they control.
  • Which transaction and output index each UTXO came from.
  • Which UTXOs have been spent.
  • Which UTXOs are currently being used by unconfirmed transactions.
  • Dependencies between transactions.

A Stage 7 wallet can handle these relationships automatically. Studying the process manually in Stage 8 prepares you to better debug wallet and application state issues in the future.

Common Beginner Misconceptions

  • New transactions cannot arbitrarily reference nonexistent outputs.
  • You spend a specific outpoint, not an account balance.
  • When Transaction B depends on Transaction A, ensure the processing node can see A.
  • The transaction chain is not the blockchain itself; it is the chain of coin or state UTXO transfers.
  • Putting application state on-chain isn't just appending a log. Many state protocols require spending old state and creating new state.

References

Recommended articles