---
title: Mining
description: "# [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) adds new blocks to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) chain, making transaction history hard to modify. ## Introduction [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) today takes on two forms: - Solo [Mining](https://bitcoindevelopers.org/encyclopedia/mining/), where the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) attempts to generate new blocks on his own, with the…"
url: "https://bitcoindevelopers.org/docs/developer-guides/mining/"
updated: "2025-05-13"
category: Developer Guides
---

# Mining

# [Mining](https://bitcoindevelopers.org/encyclopedia/mining/)

[Mining](https://bitcoindevelopers.org/encyclopedia/mining/) adds new blocks to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) chain, making transaction history hard to modify.

## Introduction

[Mining](https://bitcoindevelopers.org/encyclopedia/mining/) today takes on two forms:

- Solo [Mining](https://bitcoindevelopers.org/encyclopedia/mining/), where the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) attempts to generate new blocks on his own, with the proceeds from the [Block reward](https://bitcoindevelopers.org/encyclopedia/block-reward/) and transaction fees going entirely to himself, allowing him to receive large payments with a higher variance (longer time between payments)
- Pooled [Mining](https://bitcoindevelopers.org/encyclopedia/mining/), where the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) pools resources with other miners to find blocks more often, with the proceeds being shared among the pool miners in rough correlation to the amount of hashing power they each contributed, allowing the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) to receive small payments with a lower variance (shorter time between payments).

## Solo [Mining](https://bitcoindevelopers.org/encyclopedia/mining/)

As illustrated below, solo miners typically use `bitcoind` to get new transactions from the network. Their [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software periodically polls `bitcoind` for new transactions using the “getblocktemplate” RPC, which provides the list of new transactions plus the [Public key](https://bitcoindevelopers.org/encyclopedia/public-key/) to which the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction should be sent.

  ![Solo Bitcoin Mining](https://bitcoindevelopers.org/wp-content/uploads/2025/05/en-solo-mining-overview.svg)

Solo Bitcoin [Mining](https://bitcoindevelopers.org/encyclopedia/mining/)

The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software constructs a [Block](https://bitcoindevelopers.org/encyclopedia/block/) using the template (described below) and creates a [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/). It then sends the 80-byte [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) to its [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) hardware (an ASIC) along with a [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold ([Difficulty](https://bitcoindevelopers.org/encyclopedia/difficulty/) setting). The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) hardware iterates through every possible value for the [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) nonce and generates the corresponding hash.

If none of the hashes are below the threshold, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) hardware gets an updated [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) with a new [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) from the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software; this new [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) is created by adding extra nonce data to the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) field of the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction.

On the other hand, if a hash is found below the [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) hardware returns the [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) with the successful nonce to the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software. The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software combines the [Header](https://bitcoindevelopers.org/encyclopedia/header/) with the [Block](https://bitcoindevelopers.org/encyclopedia/block/) and sends the completed [Block](https://bitcoindevelopers.org/encyclopedia/block/) to `bitcoind` to be broadcast to the network for addition to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) chain.

## Pool [Mining](https://bitcoindevelopers.org/encyclopedia/mining/)

Pool miners follow a similar workflow, illustrated below, which allows [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool operators to pay miners based on their share of the work done. The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool gets new transactions from the network using `bitcoind`. Using one of the methods discussed later, each [Miner](https://bitcoindevelopers.org/encyclopedia/miner/)’s [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software connects to the pool and requests the information it needs to construct [Block](https://bitcoindevelopers.org/encyclopedia/block/) headers.

  ![Pooled Bitcoin Mining](https://bitcoindevelopers.org/wp-content/uploads/2025/05/en-pooled-mining-overview.svg)

Pooled Bitcoin [Mining](https://bitcoindevelopers.org/encyclopedia/mining/)

In pooled [Mining](https://bitcoindevelopers.org/encyclopedia/mining/), the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool sets the [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold a few orders of magnitude higher (less difficult) than the network [Difficulty](https://bitcoindevelopers.org/encyclopedia/difficulty/). This causes the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) hardware to return many [Block](https://bitcoindevelopers.org/encyclopedia/block/) headers which don’t hash to a value eligible for inclusion on the [Block](https://bitcoindevelopers.org/encyclopedia/block/) chain but which do hash below the pool’s [Target](https://bitcoindevelopers.org/encyclopedia/target/), proving (on average) that the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) checked a percentage of the possible hash values.

The [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) then sends to the pool a copy of the information the pool needs to validate that the [Header](https://bitcoindevelopers.org/encyclopedia/header/) will hash below the [Target](https://bitcoindevelopers.org/encyclopedia/target/) and that the [Block](https://bitcoindevelopers.org/encyclopedia/block/) of transactions referred to by the [Header](https://bitcoindevelopers.org/encyclopedia/header/) [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) field is valid for the pool’s purposes. (This usually means that the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction must pay the pool.)

The information the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) sends to the pool is called a share because it proves the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) did a share of the work. By chance, some shares the pool receives will also be below the network [Target](https://bitcoindevelopers.org/encyclopedia/target/)—the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool sends these to the network to be added to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) chain.

The [Block reward](https://bitcoindevelopers.org/encyclopedia/block-reward/) and transaction fees that come from [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) that [Block](https://bitcoindevelopers.org/encyclopedia/block/) are paid to the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool. The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool pays out a portion of these proceeds to individual miners based on how many shares they generated. For example, if the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool’s [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold is 100 times lower than the network [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold, 100 shares will need to be generated on average to create a successful [Block](https://bitcoindevelopers.org/encyclopedia/block/), so the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool can pay 1/100th of its payout for each share received. Different [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pools use different reward distribution systems based on this basic share system.

## [Block](https://bitcoindevelopers.org/encyclopedia/block/) Prototypes

In both solo and pool [Mining](https://bitcoindevelopers.org/encyclopedia/mining/), the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software needs to get the information necessary to construct [Block](https://bitcoindevelopers.org/encyclopedia/block/) headers. This subsection describes, in a linear way, how that information is transmitted and used. However, in actual implementations, parallel threads and queuing are used to keep ASIC hashers working at maximum capacity.

### getwork RPC

The simplest and earliest method was the now-deprecated Bitcoin Core `getwork` RPC, which constructs a [Header](https://bitcoindevelopers.org/encyclopedia/header/) for the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) directly. Since a [Header](https://bitcoindevelopers.org/encyclopedia/header/) only contains a single 4-byte nonce good for about 4 gigahashes, many modern miners need to make dozens or hundreds of `getwork` requests a second. Solo miners may still use `getwork` on v0.9.5 or below, but most pools today discourage or disallow its use.

### getblocktemplate RPC

An improved method is the Bitcoin Core “getblocktemplate” RPC. This provides the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software with much more information:

1. The information necessary to construct a [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction paying the pool or the solo [Miner](https://bitcoindevelopers.org/encyclopedia/miner/)’s `bitcoind` [Wallet](https://bitcoindevelopers.org/encyclopedia/wallet/).
2. A complete dump of the transactions `bitcoind` or the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool suggests including in the [Block](https://bitcoindevelopers.org/encyclopedia/block/), allowing the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software to inspect the transactions, optionally add additional transactions, and optionally remove non-required transactions.
3. Other information necessary to construct a [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) for the next [Block](https://bitcoindevelopers.org/encyclopedia/block/): the [Block](https://bitcoindevelopers.org/encyclopedia/block/) version, previous [Block](https://bitcoindevelopers.org/encyclopedia/block/) hash, and bits ([Target](https://bitcoindevelopers.org/encyclopedia/target/)).
4. The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool’s current [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold for accepting shares. (For solo miners, this is the network [Target](https://bitcoindevelopers.org/encyclopedia/target/).)

Using the transactions received, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software adds a nonce to the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) extra nonce field and then converts all the transactions into a [Merkle tree](https://bitcoindevelopers.org/encyclopedia/merkle-tree/) to derive a [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) it can use in a [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/). Whenever the extra nonce field needs to be changed, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software rebuilds the necessary parts of the [Merkle tree](https://bitcoindevelopers.org/encyclopedia/merkle-tree/) and updates the time and [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) fields in the [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/).

Like all `bitcoind` RPCs, “getblocktemplate” is sent over HTTP. To ensure they get the most recent work, most miners use HTTP longpoll to leave a “getblocktemplate” request open at all times. This allows the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool to push a new “getblocktemplate” to the [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) as soon as any [Miner](https://bitcoindevelopers.org/encyclopedia/miner/) on the [Peer](https://bitcoindevelopers.org/encyclopedia/peer/)-to-[Peer](https://bitcoindevelopers.org/encyclopedia/peer/) network publishes a new [Block](https://bitcoindevelopers.org/encyclopedia/block/) or the pool wants to send more transactions to the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software.

## Stratum

A widely used alternative to “getblocktemplate” is the Stratum [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) protocol. Stratum focuses on giving miners the minimal information they need to construct [Block](https://bitcoindevelopers.org/encyclopedia/block/) headers on their own:

1. The information necessary to construct a [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction paying the pool.
2. The parts of the [Merkle tree](https://bitcoindevelopers.org/encyclopedia/merkle-tree/) which need to be re-hashed to create a new [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) when the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction is updated with a new extra nonce. The other parts of the [Merkle tree](https://bitcoindevelopers.org/encyclopedia/merkle-tree/), if any, are not sent, effectively limiting the amount of data which needs to be sent to (at most) about a kilobyte at current transaction volume.
3. All of the other non-[Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) information necessary to construct a [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) for the next [Block](https://bitcoindevelopers.org/encyclopedia/block/).
4. The [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool’s current [Target](https://bitcoindevelopers.org/encyclopedia/target/) threshold for accepting shares.

Using the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction received, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software adds a nonce to the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) extra nonce field, hashes the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction, and adds the hash to the received parts of the [Merkle tree](https://bitcoindevelopers.org/encyclopedia/merkle-tree/). The tree is hashed as necessary to create a [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/), which is added to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) [Header](https://bitcoindevelopers.org/encyclopedia/header/) information received. Whenever the extra nonce field needs to be changed, the [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software updates and re-hashes the [Coinbase](https://bitcoindevelopers.org/encyclopedia/coinbase/) transaction, rebuilds the [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/), and updates the [Header](https://bitcoindevelopers.org/encyclopedia/header/) [Merkle root](https://bitcoindevelopers.org/encyclopedia/merkle-root/) field.

Unlike “getblocktemplate”, miners using Stratum cannot inspect or add transactions to the [Block](https://bitcoindevelopers.org/encyclopedia/block/) they’re currently [Mining](https://bitcoindevelopers.org/encyclopedia/mining/). Also unlike “getblocktemplate”, the Stratum protocol uses a two-way TCP socket directly, so miners don’t need to use HTTP longpoll to ensure they receive immediate updates from [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pools when a new [Block](https://bitcoindevelopers.org/encyclopedia/block/) is broadcast to the [Peer](https://bitcoindevelopers.org/encyclopedia/peer/)-to-[Peer](https://bitcoindevelopers.org/encyclopedia/peer/) network.

**Resources:** The GPLv3 BFGMiner [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) software and AGPLv3 Eloipool [Mining](https://bitcoindevelopers.org/encyclopedia/mining/) pool software are widely-used among miners and pools. The libblkmaker C library and python-blkmaker library, both MIT licensed, can interpret GetBlockTemplate for your programs.
