# Why miners looking for zeros?

I am trying to understand how miners work.

Is it true that miners are looking for a number of zeros because if they needed to find the complete hash they will be able to see the content of the transaction? Besides that, it is probably impossible to find a complete hash?

Please let me know if the question is unclear, thank you in advance :)

Why miners looking for zeros?

They aren't.

Is it true that miners are looking for a number of zeros ...

No.

... because if they needed to find the complete hash ...

It is nothing to do with partial or complete hashes. All hashes computed by miners are complete hashes of the hashed data.

... they will be able to see the content of the transaction?

No, miners don't need a hash in order to see the contents of the transactions.

Besides that, it is probably impossible to find a complete hash?

No. it is easy to compute a complete hash. A single modern hardware device can compute 100,000,000,000,000 complete hashes every second.

A hash is an unpredictable number between 0 and roughly 11579208923731619542357098500869123456789012345678901234567890123456789 Therefore most hashes will be very very big numbers and so it is difficult to find a set of data whose hash is in some small part of that range (e.g. within 0 to 21)

Miners are using a brute-force trial-and-error method of finding a set of data whose hash is numerically less than the current network target value.

For example, if the network target was 21, then a hash of 33 would be too big but a hash of 17 would be a winner. In Bitcoin the target numbers are currently much larger than 21 but the comparison is still numeric.

To find a set of data that hashes to a value smaller than the target they vary a part of the block data which is known as the nonce. For each variation they compute the hash and see if the hash is less than the target. There are other things the miners can change that also affect the value of the computed hash. Miners have to resort to changing these other things after they have tried every possible value of nonce.

The target is set by Bitcoin rules such that a hash less than the target will, on average, be found every ten minutes.

This is a lot of work. The arrangement of data whose hash is less than the target is proof of this work having been done. Hence the phrase proof-of-work.

A hash is just a number (often encoded in hex). If you take arbitrary input data and run it through a hash function, you'll get back the 'hash' of that data. In the case of SHA256, the hash will be a number somewhere in the range of 0 to 2^256. There is no way to guess what the output will be for a given input, other than just running the hash function to see what happens.

What bitcoin miners are doing is trying to create a block template that includes a block header that will hash to a number that is under some network-defined value (the 'target'). In practice, this means that the valid hashes they find will start with a bunch of zeros, since the goal is to find a hash output that is less than the target. Miners will already know the transactions that they included in the block are valid, finding a valid hash does not change their ability to see or validate transactions. A valid hash is simply the 'proof of work' to show that the miner spent some amount of energy to create the block.

• Thank you both! Really appreciate it :) I don't know why but somehow I was assuming that based on the content (the transactions) in the blockchain there was already a hash and miners needed to guess this hash by increasing the nonce. If I understand it correctly it is the miner that creates the hash?
– Timo
Nov 3, 2021 at 19:56
• Transactions are hashed (hashes are used for various things in Bitcoin) but the miners don't change the transaction to try to get a particular hash like they do with the nonce in the block header. Transactions (and hence the transaction hash) don't get changed by the miner. Nov 3, 2021 at 20:04

Miners are looking for hash with a number of leading zeros because if they do they can announce it and claim the coinbase (or mining reward). They can already see the content of every transaction that they have received through network gossip.

it is probably impossible to find a complete hash?

I'm not sure what you mean by "complete". If you mean a hash of all zeros that is answered here.