POW parameters – target

As you know, proof of work is the consensus mechanism used in Bitcoin to validate (mine) the blocks. It's a repetitive brute-force process aiming at finding the hash that meets specific requirements. Each hash basically gives a random number between 0 and the maximum value of a 256-bit number (which is huge). If the miner's hash is below the given target (a special hash value), then he wins. If not, he increments the nonce (completely changing the hash) and tries again.

The target is a 256-bit number that represents a threshold. Actually, it represents a threshold such that the SHA-256 hash of a candidate block's header must be lower than or equal to it in order to be accepted as valid and added to the blockchain:

In the chainparams.cpp file, there is a powLimit parameter that describes the absolute highest target, which, at the same time, is the lowest possible difficulty:

consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

This limit represents, by definition, a difficulty of 1. In order to produce blocks every 2.5 minutes, we use the following value instead:

consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

This target can also be represented in the code by nBits=0x1e0ffff0. In fact, the variable genesis.nBits defined in chainparams.cpp represents the compacted form of the target powLimit value.

In the same file, Bitcoin also defines the following parameter:

consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000001b3fcc3e766e365e4b");

This specifies the minimum amount of chain work that a client must have before it will consider itself synchronized. As we are running a new chain, the minimum should be zero for both testnet and mainnet:

consensus.nMinimumChainWork = uint256S("0x00");