# What are the hashes that miners need to do to create a block? [duplicate]

I’m bit stuck in the concept of mining.

What are the hashes that need to be created in each block and the chain? Let’s say that we have block A - B - C forming a chain.

One source said that we need to come up with the hash of A and combine it with previous block’s hash forming another has, in other words: hash(A + previous block’s hash).

Another source just says that it’s just hash of the block itself, and in that block we specify the hash of the previous block’s hash.

The concept of Proof of Work is that you have X and you have an output of Z, what is the Y needed, so hash(X + Y) = Z.

If that's the case, can we say that X is the previous block's hash, and Y is the hash of the current block? Or am I looking this wrongly?

## marked as duplicate by alcio, pebwindkraft, Osias Jota, Andrew Chow♦Mar 18 '18 at 21:31

Another source just says that it’s just hash of the block itself, and in that block we specify the hash of the previous block’s hash.

This is correct. The others are varying degrees of correct and incorrect. But this is the only one that is absolutely correct.

The concept of Proof of Work is that you have X and you have an output of Z, what is the Y needed, so hash(X + Y) = Z.

If that's the case, can we say that X is the previous block's hash, and Y is the hash of the current block? Or am I looking this wrongly?

Kind of.

The block consists of multiple fields. It can first be broken down into two major parts: the block header, and the transactions themselves. All of the block is hashed in some way.

The hash of the block header is what we call the hash of the block. The hash of the block header is also what is used for the proof of work. When you interpret the block header's hash (also known as the block hash) as a 256 bit little endian integer, it must be less than a calculated target (also a 256 bit integer).

The block header itself can be broken further down into multiple parts. It contains the block version number, the previous block's hash, the hash of all of the transactions in the block, a timestamp, a compact representation of the target value, and a nonce.

Since the block header includes the previous block's hash, the block header's hash is really just the hash of the block (as it contains the hash of all of the block's transaction) in which the previous block's hash is specified within it.

In order to mine blocks, miners will tweak the fields in the block header until they get one that meets the target. Typically they change the nonce value (it's just a number) and the hash of all of the transactions in the block (by changing the coinbase transaction, choosing new transactions, and changing the order of transactions). Miners may also change the timestamp and the version number.

• Thank you for the answer! If I got this correctly: A block contains block version number, previous block's hash, information (transactions, timestamp other data) and a nonce. Miners try to tweak nonce (usually) or transactions inside to meet the desired hash. Is that correct? Who gets to choose the hash that must be met so the new block can be mined? – Nelsen Liu Mar 11 '18 at 6:20
• @NelsenLiu yea, you're on the right track! The hash is not required to be a certain value, rather the hash must be within some pre-defined range of values. That range is defined by the current network difficulty, which sets a maximum value for a valid block hash. – chytrik Mar 11 '18 at 9:24
• The target value is determined individually by each node. It is a deterministic algorithm so everyone who is using the same blockchain will end up calculating the same difficulty for each block height. – Andrew Chow Mar 11 '18 at 15:35