Nonce
- Category
- Blockchain
- Level
- Professional
Simple definition
A number a miner changes again and again, hunting for one that makes the block's hash small enough to pass the network's test.
Professional definition
In proof-of-work mining, the header field varied in search of a hash at or below the current target. In account-based chains the word carries a second, unrelated meaning: a per-account counter that orders a sender's transactions and blocks replay.
Technical definition
A search variable, not a secret. Because the header hash behaves as unpredictable, no strategy beats brute force, so expected attempts scale with difficulty and the winning nonce carries no information. Bitcoin's header nonce is 32 bits, about 4.3 billion candidates, which modern hardware exhausts in a fraction of a second, so miners also vary the coinbase extranonce, the timestamp and the transaction set to enlarge the search space.
Academic definition
A free parameter of a block header searched until the header hash satisfies a predicate fixed by the consensus target; in account-based ledgers, alternatively a monotonic per-account sequence number enforcing transaction ordering and replay protection.
Mechanism
The search works only because the hash is unpredictable: flipping one bit of the nonce rewrites the whole output, so candidates cannot be ordered or pruned. That is what makes the work measurable and unforgeable — each attempt is an independent draw, and the only way to show you made many is to produce a winner.
In practice
- Who uses it
- Mining firmware and pool engineers, protocol implementers, and wallet developers who must manage account nonces correctly.
- Why it matters
- The mining nonce is where the cost of proof of work is actually paid; the account nonce is what keeps a signed transaction from being replayed.
- Limitations
- A nonce proves nothing on its own. Only the resulting hash against the target has meaning, and account nonces are protocol-specific.
Common mistakes
- Confusing the mining nonce with the account nonce in Ethereum.
- Thinking a lucky nonce can be predicted or precomputed.
- Reusing or skipping an account nonce and stalling a wallet's queue.
Examples
A pool hands each machine a different extranonce range so two workers never test the same header twice. The nonce field alone is far too small to keep an industrial farm busy.
If a hash is modelled as uniform over 256 bits and the target is 2^224, one attempt in about 4.3 billion succeeds, so the expected number of nonces tried before a valid block is roughly 2^32.
- hash output = 256 bits, modelled as uniform
- target T = 2^224
- trials are independent
- P(success per attempt) = (T + 1) / 2^256 ~ 2^224 / 2^256 = 2^-32
- E[attempts] = 1 / 2^-32 = 2^32
An idealisation. Real targets are not powers of two and real hash functions are only assumed to behave uniformly.
Mathematical foundation
Variables
| H | The chain's hash function, here a 256-bit digest | bit string |
| T | Current target: the largest hash value accepted as valid | integer |
| \text{nonce} | The searched header field | integer |
Procedure
Assemble the header, hash it, and compare the digest read as an integer with the target. If it is larger, change the nonce and hash again. When the nonce range is exhausted, change the extranonce, timestamp or transaction set and continue.
Worked example
- T = 2^224
- H outputs 256 bits, modelled as uniform
- P = 2^224 / 2^256 = 2^-32
- E[attempts] = 2^32
Interpretation
The expected attempt count is the protocol's price list: it says how much computation a valid block should cost at the current target. Any single block can be found on the first try or the trillionth.
Assumptions
- The hash function is modelled as a uniform random function; this is an assumption about SHA-256, not a proven property.
- Attempts are independent, so the search is memoryless and past failures do not raise the next attempt's chance.
- Written for a 256-bit digest; the exponent changes with the digest length.
- The formula gives an expectation, not a schedule: realised times per block are exponentially distributed.
- It describes the mining nonce only. The account nonce of an account-based chain has no probabilistic content at all.
Related terminology
Cryptographic Hash
The hash is the function. The nonce is one input fed to it over and over. Changing the nonce does not change the function, only the attempt.
Sources
bitcoin.org · 2008-10-31 · section 4: proof-of-work, incrementing a nonce until the hash meets the required zero bits
https://bitcoin.org/bitcoin.pdf URL verified
O'Reilly · 2017 · mining chapter: nonce range, extranonce and the search space
Print source
Ethereum Foundation · entry for nonce, account sequence number sense
https://ethereum.org/glossary/ URL verified
Editorial status
Flagged by the editor as uncertain on a linguistic, mathematical or regulatory point.
