How Does a Miner Calculate the “Target” Value for a Valid Block Hash?

The target value is derived from the "bits" field in the block header, which is a compressed representation of the target. The miner must find a nonce such that the SHA-256 hash of the block header is numerically less than or equal to this target value.

The target is recalculated every 2016 blocks based on the previous mining speed to adjust the difficulty.

What Is the Specific Output Length of a Bitcoin Address in Bits?
What Is the Purpose of the ‘Nonce’ Field in a Cryptocurrency Block Header?
What Is a Nonce in the Context of PoW?
How Does a Miner Know When a Valid Hash Has Been Found?
What Is the Consequence of a Hash Being Exactly Equal to the Difficulty Target?
How Does the Size of the Nonce Field Affect the Mining Process?
What Is the Difference between a Nonce and an Extranonce?
Relate the Concept of ‘Nonce’ in Mining to the ‘Nonce’ in ECDSA Signing

Glossar