Backup Transaction Chain
A backup transaction chain is a sequence of pre-signed transactions that lets each statechain owner exit on-chain.
Key Takeaways
- A backup transaction chain is a growing sequence of pre-signed transactions created during statechain transfers, where each new transaction has a shorter timelock than the one before it.
- The decrementing timelock ordering guarantees that the most recent owner can always claim funds on-chain before any previous owner, providing a trustless unilateral exit without cooperation from the statechain entity.
- The chain length is bounded: each transfer consumes a fixed number of blocks from the initial timelock, so the coin must eventually be settled on-chain and re-deposited to continue trading off-chain.
What Is a Backup Transaction Chain?
A backup transaction chain is the ordered sequence of pre-signed transactions that accumulates as a statechain coin changes hands. Every time ownership of the coin transfers from one party to the next, a new backup transaction is created and appended to this chain. Each backup spends the same on-chain UTXO (the original funding output locked in a 2-of-2 multisig), but each one carries a progressively shorter nLockTime value. This decrementing pattern is the mechanism that determines who gets to exit first if the statechain entity goes offline.
The concept was introduced as part of the statechain protocol proposed by Ruben Somsen in 2018. His original design envisioned using SIGHASH_ANYPREVOUT (then called SIGHASH_NOINPUT) to allow newer state updates to override older ones. Because that opcode has not been activated on Bitcoin, practical implementations like Mercury Layer instead use decrementing nLockTime values to achieve a similar ordering guarantee using features available in Bitcoin today.
How It Works
The backup transaction chain is built incrementally. Each transfer between owners adds one link to the chain. The chain does not exist as a connected sequence of transactions on the blockchain: all backup transactions independently spend the same original funding UTXO. What makes them a "chain" is their ordered relationship through decreasing timelocks.
Chain Construction Step by Step
- A user deposits Bitcoin into a 2-of-2 multisig address shared with the statechain entity. Before funding, the first backup transaction is created with the longest nLockTime (for example, 1,000 blocks into the future). This backup pays to the depositor's own address.
- When the coin is transferred to a second owner, a new backup transaction is co-signed by the outgoing owner and the statechain entity. This backup pays to the second owner's address and uses a shorter nLockTime (for example, 800 blocks into the future, a decrement of 200 blocks).
- Each subsequent transfer repeats the process: a new backup is co-signed with an nLockTime decremented by the same fixed interval. The third owner gets a backup at 600 blocks, the fourth at 400, and so on.
- Every owner stores their backup locally. Under normal operation, none of these transactions are ever broadcast.
Timelock Priority and Exit Ordering
The decrementing timelocks create a strict priority ordering for on-chain exits. If the statechain entity disappears and all owners broadcast their backup transactions simultaneously, only the most recent owner's transaction will succeed: it has the shortest nLockTime and becomes valid for mining first.
# Statechain coin funded at block 850,000
# Decrement interval: 200 blocks
Transfer 0 (Alice deposits): nLockTime = 851,000 (850,000 + 1,000)
Transfer 1 (Alice → Bob): nLockTime = 850,800 (851,000 - 200)
Transfer 2 (Bob → Carol): nLockTime = 850,600 (850,800 - 200)
Transfer 3 (Carol → Dave): nLockTime = 850,400 (850,600 - 200)
Transfer 4 (Dave → Eve): nLockTime = 850,200 (850,400 - 200)
# If the statechain entity goes offline at block 850,100:
# Eve broadcasts at block 850,200 → confirmed first
# Dave's tx valid at 850,400 → UTXO already spent by Eve
# Carol's tx valid at 850,600 → UTXO already spent
# All earlier backups are permanently invalidatedBecause every backup transaction spends the same UTXO, once any one of them confirms, the others become invalid. The timelock ordering ensures that the current owner always wins this race.
The nLockTime Field
The backup transaction chain relies on Bitcoin's native nLockTime field, an absolute timelock present in every Bitcoin transaction. When set to a block height, nLockTime prevents the transaction from being included in a block until that height is reached. Miners will not accept the transaction into a block template before the specified height, and nodes will not relay it. This enforcement happens at the consensus layer, so it requires no trust in the statechain entity.
// Simplified backup transaction structure
{
"version": 2,
"locktime": 850600, // Cannot be mined before block 850,600
"vin": [{
"txid": "funding_tx_id", // Spends the original multisig UTXO
"vout": 0,
"sequence": 0 // Must be 0 to enforce nLockTime
}],
"vout": [{
"value": 0.099, // Amount minus fee
"scriptPubKey": "..." // Current owner's address
}]
}The nSequence value must be set below 0xFFFFFFFF for nLockTime enforcement to take effect. Mercury Layer v0.2.0 addressed a vulnerability where default sequence values could bypass locktime checks by explicitly setting nSequence to zero in all backup transactions.
Transfer Limit and Chain Length
The decrementing timelock design imposes a hard cap on how many times a statechain coin can change hands before it must be settled on-chain. The maximum number of transfers is determined by dividing the initial timelock window by the per-transfer decrement interval.
max_transfers = initial_locktime_window / decrement_interval
# Example:
# Initial window: 1,000 blocks (~1 week)
# Decrement per transfer: 200 blocks (~1.4 days)
# Max transfers: 1,000 / 200 = 5 transfers
# With a larger window:
# Initial window: 4,032 blocks (~4 weeks)
# Decrement per transfer: 144 blocks (~1 day)
# Max transfers: 4,032 / 144 = 28 transfersOnce the nLockTime of the latest backup transaction approaches the current block height, no more off-chain transfers can occur. The coin must be settled on-chain (the current owner broadcasts their backup or cooperates with the statechain entity to close cleanly). The owner can then create a fresh statechain deposit with a new, full-length timelock window to resume off-chain trading.
This creates an inherent trade-off for protocol designers:
- A smaller decrement interval allows more transfers per coin lifetime but reduces the time gap between successive owners' exit windows, requiring faster monitoring and response
- A larger decrement interval provides wider exit windows and more safety margin but limits total transfers before an on-chain reset is needed
- A longer initial timelock window supports more transfers but means the first owner must wait longer before their backup becomes valid in the worst case
Why It Matters
The backup transaction chain is what makes statechains a self-custodial protocol rather than a purely trusted one. Without this mechanism, users would depend entirely on the statechain entity to authorize withdrawals. With it, every owner holds a cryptographic guarantee that they can exit to the Bitcoin base layer independently.
This matters because statechains involve a semi-trusted operator. The statechain entity co-signs transfers and is trusted to delete its old key shares after each ownership change. If the entity acts dishonestly or goes offline, the backup transaction chain ensures that users are not trapped. The most recent owner always has the fastest path to on-chain settlement.
Protocols like Spark build on the statechain model and extend it with FROST threshold signatures and tree-structured exits. While Spark's architecture differs from the original statechain design, the underlying principle remains: users should always hold pre-signed exit data that enables unilateral withdrawal to the base layer without operator cooperation. For a detailed comparison of exit mechanisms across Bitcoin Layer 2 protocols, see the statechains scaling deep dive.
Use Cases
Unilateral Exit Without Cooperation
The primary use case is guaranteeing that the current statechain owner can exit to the Bitcoin base layer even if the statechain entity shuts down, is censored, or refuses to cooperate. The owner simply broadcasts their backup transaction after the nLockTime matures. No permission is needed from any party.
Protection Against Previous Owners
Because the statechain entity is trusted to delete its old key shares, there is a risk that a previous owner could collude with a compromised entity to attempt a double spend. The backup transaction chain mitigates this: even if a previous owner broadcasts their old backup, the current owner's shorter timelock ensures they can claim the funds first. The previous owner's transaction will fail because the UTXO will already be spent.
Mercury Layer Coin Trading
Mercury Layer, the most prominent statechain implementation, uses backup transaction chains to enable off-chain trading of fixed-denomination Bitcoin UTXOs. Each trade appends a new backup to the chain, allowing the coin to circulate among participants without touching the blockchain until the timelock window expires or a user chooses to settle.
Risks and Considerations
Finite Transfer Capacity
The most significant limitation of the backup transaction chain model is the hard cap on transfers. Unlike Lightning channels, which can process an unlimited number of state updates, a statechain coin can only change hands a fixed number of times before requiring on-chain settlement. This makes statechains better suited for lower-frequency, higher-value transfers rather than micropayments.
Timing and Monitoring
The current owner must be aware of when their backup transaction's nLockTime will mature and be prepared to broadcast if the statechain entity becomes unresponsive. Applications and watchtower services can automate this monitoring, but users should understand that recovery is time-sensitive. Missing the broadcast window could allow a previous owner with an earlier-maturing backup to claim the funds, though this scenario requires collusion with the statechain entity.
Fee Rate Uncertainty
Backup transactions are signed with a predetermined fee rate at the time of transfer. If Bitcoin's fee market has risen significantly by the time the backup needs to be broadcast, the transaction may take longer to confirm or may not confirm before a competing backup matures. Some implementations use CPFP or anchor outputs to let users bump fees at broadcast time.
No Penalty for Cheating Attempts
Unlike Lightning's justice transaction mechanism, which punishes a cheating counterparty by confiscating all channel funds, the backup transaction chain relies solely on timelock ordering. A previous owner who broadcasts an outdated backup does not lose anything beyond the transaction fee: their attempt simply fails because the UTXO is already spent. This lack of economic penalty means the security model depends on the statechain entity faithfully deleting old key shares after each transfer.
Sequence Number Vulnerabilities
The nLockTime enforcement in Bitcoin depends on the transaction's nSequence field being set below the maximum value (0xFFFFFFFF). If a backup transaction is constructed with the default maximum sequence number, nLockTime is effectively disabled, allowing the transaction to be broadcast at any time. This vulnerability was identified in Mercury Layer and patched in version 0.2.0 by explicitly setting nSequence to zero in all backup transactions.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.