Chapter 4 of 8 Coin Selection
0%

How Wallets Choose
Which UTXOs to Spend

Your wallet holds a collection of UTXOs. When you send a transaction, a coin selection algorithm decides which ones to consume. This choice affects fees, privacy, and the long-term health of your wallet.

The problem is surprisingly deep. Say you want to send 65 ₳ and your wallet holds UTXOs of 5, 8, 10, 12, 15, 20, 30, and 50 ₳. There are multiple valid combinations: 50 + 20 (change: 5 ₳), 50 + 15 (exact match!), 30 + 20 + 15 (change: 0), 30 + 20 + 10 + 5 (change: 0), and many more. Each choice has consequences.

More inputs means a larger transaction in bytes, which means higher fees. But always picking the biggest UTXOs leaves behind a growing pile of tiny “dust” UTXOs that become uneconomical to spend. And linking UTXOs together in a single transaction reveals they belong to the same owner, affecting privacy.

This is why coin selection algorithms exist: to balance these competing goals automatically.

Selection Strategies

Three major approaches, each with distinct trade-offs.

Strategy 1

Largest First

Always picks the biggest available UTXOs until the target amount is covered. Simple, fast, predictable.

Simple to implement
Minimizes input count
Creates dust over time
Poor privacy (predictable)
Strategy 2

Random Improve

Randomly selects UTXOs to cover the amount, then tries to improve by swapping to produce a change output close to the wallet’s average UTxO size.

Keeps UTxO set healthy
Better privacy (random)
Used by Cardano wallets
Sometimes suboptimal fees
Strategy 3

Exact Match

Tries to find a combination that exactly equals the target (no change needed). Falls back to other strategies when no exact match exists.

No change output needed
Smallest possible transaction
NP-hard in general
Rarely finds exact matches
Property Largest First Random Improve Exact Match
Input countMinimalVariableVariable
Fee efficiencyGood short-termBalancedOptimal (if found)
UTxO set healthDegrades over timeMaintains balanceDepends on fallback
Change outputUsually smallTargets average sizeNone (ideal case)
PrivacyPredictable patternRandomizedMinimal footprint
Computational costO(n log n)O(n)NP-hard

Try It Yourself

Enter a send amount and see how each algorithm picks UTXOs from the same wallet.

Coin Selection Simulator

Send
Wallet UTXOs150
5 8 10 12 15 20 30 50
Selection Result
Inputs2 UTXOs
Total Selected80 ₳
Send Amount65
Change15 ₳
Est. Tx Size580 bytes
UTXO HealthModerate
After Transaction85
581012152015change

The Dust Problem

When UTXOs become so small they cost more in fees to spend than they are worth, they are called “dust”. Bad coin selection creates dust. Good coin selection prevents it.

Wallet Health Comparison: After 20 Transactions
Random Improve
42 ₳
38 ₳
25 ₳
31 ₳
18 ₳
27 ₳

6 UTXOs · avg 30 ₳ · no dust

Largest First
85 ₳
0.3 ₳
1.2 ₳
12 ₳
0.8 ₳
2.1 ₳
0.5 ₳
1.7 ₳
7 ₳
0.2 ₳

10 UTXOs · 6 dust · fragmented

Why Dust Matters

On Cardano, every UTxO has a minimum ada requirement (minUTxO). A UTxO must hold enough ada to cover its on-chain storage cost. Dust UTXOs below this threshold cannot even be created. This is a protocol-level defense against UTxO set bloat, but smart coin selection is still essential to keep wallets efficient and fees low.

Selection & Privacy

Every transaction links its inputs together. Coin selection directly impacts how much of your wallet structure you reveal on chain.

When multiple UTXOs are spent together in one transaction, an observer can conclude they belong to the same owner. This is called the “common input ownership heuristic”. The more UTXOs you combine per transaction, the more you reveal.

Largest First is the worst for privacy because it always picks the same UTXOs in the same order, making your spending patterns predictable. Random selection breaks this pattern and makes chain analysis harder.

Exact Match is the best for privacy in the rare cases where it works, because it uses only the inputs needed with no change output. A change output reveals that one of the two outputs goes back to you.

Change Output Analysis

When a transaction has two outputs, chain analysts try to figure out which one is the payment and which is the change. Round amounts are usually payments (50 ₳). Odd amounts are usually change (13.847 ₳). Good wallets can mitigate this with techniques like multiple change outputs or change address rotation.

Coin Selection on Cardano

Cardano’s eUTxO model adds unique considerations to coin selection: native tokens, datum storage, and multi-asset UTXOs.

Multi-asset UTXOs make selection harder. A single UTxO on Cardano can carry ada plus multiple native tokens. When you want to send a specific token, the algorithm must also consider the ada bundled with it, and ensure the remaining ada covers minUTxO requirements.

Datum size affects fees. UTXOs locked at script addresses carry datums, which increase the transaction size. Coin selection must account for the byte cost of including datum-heavy UTXOs as inputs.

Cardano wallets (like Lace and Eternl) use variants of Random Improve, adapted for multi-asset selection. The algorithm first selects enough to cover the ada requirement, then ensures all requested tokens are also covered, and finally optimizes the change output to maintain a healthy UTxO distribution.

CIP-2: Coin Selection Specification

Cardano has a formal Improvement Proposal (CIP-2) that specifies coin selection algorithms. It defines the Random Improve strategy as the recommended approach and provides detailed guidance on handling multi-asset selection, change output optimization, and fallback strategies.

Mastery Check

Three quick questions

Optional. Score 3/3 to earn mastery badges. Your first attempt counts for the Polymath badge.