Who wants to be a OneCoin millionaire? YOU don’t – here’s why hyped-up web currency is virtually worthless Bitcoin is the virtual currency world leader and it is claimed that OneCoin comes next, but something doesn’t add up Share Comments 17:20, ten FEB 2016 Updated 08:04, twelve FEB 2016 Share Comments Welcome to a get-rich-quick […]

# blockchain nonce

Get via App Store Read this post in our app!

## When a block is "discovered" how is the nonce determined?

I know that a block is based on a random number called a nonce, but if that number is random and unknown to the miner, how is that number actually verified as the correct nonce and not some arbitrary number?

## 1 Response

Basically, **there is no such thing as a “correct” nonce, only a set of possible “correct” blocks which can use any nonce they wish to obtain an acceptable hash. So the nonce is just “some arbitrary number”.** But in order to understand how nonces work, you very first have to understand the hashing process by which blocks are produced.

Cryptographic hashes are a mathematical way of turning any set of data into a random number, called a hash. The hashing process is designed so that it’s effortless to calculate the hash of some data but almost unlikely to find data which will fit a specific hash, having even a slightly different set of data will produce a totally different hash, and so that the only way to find a hash with a particular property (say, being below a certain number) is to calculate lots of them until you get fortunate.

**In the Bitcoin network, only blocks with certain hashes get accepted and included in the official list.** The criteria for which blocks “count” is that their hash has to be below a certain number called the target. The network adjusts this number up and down according to how frequently blocks are passing the test–this is how it’s able to keep the rate of block production at an average of ten minutes per block. So if the target is

then a block with a hash of

won’t be accepted, but blocks with hashes of

will all pass with flying colours. These aren’t real hashes–they’re just examples.

A miner is taking a list of checked and valid transactions, putting them together in the right format, and then calculating their cryptographic hash. But let’s say that the hash they get doesn’t meet the criteria (as most of them don’t). What are they supposed to do? **The only way to get a different hash is to use at least slightly different data.** So instead of messing up their list of valid transactions or anything like that, blocks have something called a nonce in them. **The nonce is just a meaningless number that can be switched as many times as you like so that you can check a bunch of different hashes and see whether they pass the network’s difficulty check.** So when a miner is checking billions of hashes per 2nd (as many of them are) they are just switching the nonce to something else, checking the hash of the entire block; switching the nonce to something else, checking the hash of the (now slightly different) block; switching the nonce again, etc.

In this sense **a “correct” nonce is simply the one that permits the block to hash to an acceptable number.** Just like there are many acceptable hashes, there are many different nonces which will work for the same block. But a miner only has to find one of them. Whichever one they find very first is just fine.

You may also be interested in how the target is calculated.