Block Template

The candidate block a miner hashes: chosen transactions, coinbase payout, and header fields.

Basically

A block template is a draft Bitcoin block filled with chosen transactions. A miner uses it while trying to find the special result needed to make the block valid.

Key Takeaways

  • A block template is the candidate block a miner assembles from mempool transactions before searching for a valid proof-of-work hash. It defines which transactions are confirmed and their order.
  • Template construction selects transactions by fee rate, builds a Merkle tree and sets six block header fields: version, previous block hash, Merkle root, timestamp, difficulty target and nonce.
  • Template builders affect decentralisation. Stratum V1 gives mining pools control over transaction selection, while Stratum V2 lets individual miners construct their own templates.

What Is a Block Template?

A block template is the pre-assembled structure of a candidate Bitcoin block. It contains selected mempool transactions, a coinbase transaction that pays the miner and a fully populated 80-byte block header. The miner must find a nonce value that, when hashed with the header, produces a hash below the current difficulty target.

Block templates determine which transactions the Bitcoin network confirms. The template builder decides which transactions are included, which are excluded and their order in the next block. Template construction therefore has a direct effect on how Bitcoin operates.

How It Works

Block template construction turns unconfirmed transactions into one candidate block ready for mining. The process selects and orders transactions, builds the Merkle tree and fills in the block header.

Block Header Fields

The block header is exactly 80 bytes and contains six fields that together define the candidate block. The fields are version, previous block hash, Merkle root, timestamp, difficulty target and nonce.

Transaction Selection Algorithm

Bitcoin Core uses the ancestor fee rate algorithm, introduced in PR #7600, to select the transactions that fill a block template. The selection process then builds the candidate block from those transactions.

The algorithm enables Child Pays for Parent (CPFP): a high-fee child transaction raises the ancestor package fee rate and pulls its low-fee parent into the block. Miners can also use the prioritisetransaction RPC to change a transaction's effective fee for template construction and manually adjust its priority.

Cluster Mempool

Bitcoin Core v31.0 introduces cluster mempool, a redesigned mempool data structure that improves template construction. Related unconfirmed transactions form clusters bounded at 64 transactions or 101 kB, and each cluster is linearised into an optimal ordering of "chunks" sorted by fee rate. Template construction then includes chunks in decreasing fee rate order until the block is full, replacing the ancestor fee rate heuristic with a more globally optimal selection strategy.

The getblocktemplate RPC

Mining software uses the getblocktemplate RPC, defined in BIP 22 and extended by BIP 23, to request block templates from a Bitcoin node. It replaced the older getwork protocol in 2012. It sends the full block structure rather than just a header, so miners can inspect and optionally modify the template.

The response includes a mutable array listing what the miner may change, typically the timestamp, coinbase data and transaction set. BIP 23 added a "proposal" mode that lets miners submit a fully constructed block for the pool to validate before actual mining begins.

BIP 145 requires the request to specify the segwit rule. The response then includes witness data for each transaction and a default witness commitment that the miner must include as a coinbase output.

Who Builds the Template

Control over block template construction is a central question in Bitcoin mining. The mining protocol in use determines who has that control.

Stratum V1: Pool-Controlled Templates

Stratum V1, the dominant mining protocol since 2012, gives the mining pool control over block template construction. The pool runs a full node, calls getblocktemplate, selects transactions, constructs the coinbase and distributes work to miners, who hash against the supplied template without any input on transaction selection. A small number of pool operators therefore hold concentrated transaction selection power.

Stratum V2: Miner-Selected Templates

Stratum V2 adds an optional Job Negotiation Protocol that lets individual miners running their own full nodes construct block templates from their own mempools. The miner proposes a template to the pool, which validates it and attributes the work. The protocol decentralises transaction selection by returning it to individual miners.

Stratum V2 also encrypts communication to prevent hashrate hijacking, cuts bandwidth use by approximately 60-70% and reduces block switching latency from roughly 325 milliseconds to under 2 milliseconds. Pools representing approximately 75% of global hashrate had joined the Stratum V2 Working Group as of mid-2026.

Why It Matters

Block template construction is central to Bitcoin's security model. It determines which transactions are confirmed, how quickly the mempool clears and whether the network remains censorship-resistant. The Bitcoin fee market dynamics research article gives a deeper analysis of how fees and template economics interact.

Layer-2 protocols such as the Lightning Network and Spark depend on block templates because their on-chain settlement transactions must eventually enter a block. Time-sensitive transactions, including justice transactions, channel closes and HTLC timeouts, depend on predictable block inclusion. Developers need to know how templates are constructed to set appropriate fee rates and timeouts for these critical transactions.

Miners can directly increase revenue through template optimisation. Selecting the highest-fee transactions within the weight limit maximises the fees collected in each block. The mining economics in 2026 research article examines how the declining block subsidy makes transaction fee revenue increasingly important.

Centralisation of Template Construction

Stratum V1 leaves control over the transactions in virtually all blocks with a handful of pool operators. Collusion between a few pools, or regulatory coercion, could let them censor specific transactions. Reducing this centralisation risk is a primary motivation behind Stratum V2's miner-selected template feature and projects such as the Stratum Reference Implementation (SRI).

MEV and Front-Running

Miner Extractable Value (MEV) is the profit miners can capture by manipulating transaction ordering within their templates. Bitcoin's simple UTXO transactions historically kept MEV minimal, but metaprotocols such as Ordinals and BRC-20 tokens have introduced new front-running vectors. Capped minting operations create race conditions in which bots scan the mempool and submit competing transactions with higher fees.

Out-of-Band Fee Payments

Transaction accelerator services let users pay mining pools directly, via Lightning or fiat, to prioritise specific transactions. These out-of-band payments are convenient for users but create fee revenue that other nodes' fee estimation algorithms cannot see. Bitcoin's fee market becomes less transparent as a result, and its censorship resistance may also be weakened.

Template Staleness

A new network block makes all current templates stale because they reference an outdated previous block hash. Miners must switch quickly to a new template or risk mining an orphaned block, so low-latency template updates prevent wasted hashrate and lost revenue and provide a competitive advantage. Stratum V1 takes roughly 325 milliseconds on average for this switch, while Stratum V2 reduces the latency to under 2 milliseconds.

Nuri provides this glossary entry for information only, not as financial or investment advice. You should always do your own research before using any protocol or technology.

0

← All 1876 glossary terms