Transaction Ordering
Transaction ordering is how miners arrange selected transactions inside a block template to maximize revenue while maintaining validity.
Definition
Transaction ordering is the way miners arrange selected transactions inside a candidate block before mining it. The order must follow the network’s validation rules, but miners or mining pools often have some choice in how valid transactions are sequenced. Unlike transaction selection, which decides what goes into a block, ordering decides where each transaction sits relative to the others.
How It Works
A miner starts by pulling transactions from the mempool, the waiting area for unconfirmed payments. These are placed into a block template, the draft block that mining hardware will hash.
The first transaction is always the coinbase transaction. It creates the block reward and collects aggregated fees. After that, normal user transactions follow.
Dependency constraints
Ordering cannot ignore parent-child dependencies. If a child transaction spends outputs created by an unconfirmed parent, the parent must appear first in the block. A block that violates this rule is invalid — the child appears to spend coins that do not yet exist, and every node on the network will reject it.
Fee-rate sorting and ancestor packages
Bitcoin Core’s mining algorithm does not sort transactions by raw fee rate alone. Instead, it uses ancestor fee rate sorting: each transaction’s effective fee rate includes the fees of all its unconfirmed ancestors. A low-fee parent bundled with a high-fee child may have a higher ancestor fee rate than an unrelated transaction with a moderate individual fee rate. This package-aware approach lets miners maximize total block revenue rather than greedily picking the highest individual fee rates.
The algorithm works in rounds. First, it selects the transaction with the highest ancestor fee rate, then updates the remaining candidates’ effective rates since their dependency chains have changed. It repeats until the block template is full.
Merkle root linkage
Once the order is set, transactions are hashed into a Merkle root that goes into the block header. Changing the order changes the Merkle root, which changes what miners hash during proof of work. This means the ordering decision is baked into the PoW puzzle itself.
Value extraction and MEV
In Bitcoin’s UTXO model, direct reordering-based value extraction is limited compared to smart-contract chains. There is no mempool-based DEX to sandwich. However, ordering does create subtle advantages. A miner who mines their own transaction can guarantee placement order, which matters for time-sensitive operations like closing Lightning channels or claiming outputs from competing transactions. On chains with expressive scripting (Ethereum, Solana), ordering enables full MEV — searchers pay block producers to place their transactions first in profitable arbitrage or liquidation sequences.
Why It Matters
A bad order makes a block invalid. If a miner finds a valid hash for a block with incorrectly arranged transactions, the network rejects it and the miner loses the reward entirely.
Good ordering increases revenue. By using ancestor fee rate sorting instead of naive per-transaction sorting, miners can capture more total fees from the same block space. During congestion periods, this difference compounds.
Ordering also shapes power dynamics in mining. In traditional pools, the operator builds the block template — individual hashers never choose the order. Stratum V2 changes this by letting miners construct their own templates, which means they can apply their own ordering strategies rather than accepting the pool’s. This reduces trust assumptions and makes censorship by pool operators harder, since hashers can override a template they disagree with.