<p>I found the answer. However please correct me if there's I'm wrong in explaining this.</p>

<p>Basically, once we have inputs for the block, we hash the data. This hashing can be achieved using multiple techniques viz. SHA256, scrypt, X11, etc. </p>

<p>The issue with generating a hash for the genesis was I used scrypt algorithm to generate the hash. You may come across paste bin links with this method <code>scrypt_1024_1_1_256_sp_sse2</code>. </p>

<p>So in my case, I replaced this with the method offered by <code>uint256</code> class. You can find this genesis creation logic at <a href="https://pastebin.com/burynTft" rel="nofollow noreferrer">this pastebin</a>.</p>

<p>Feel free to add anything or correct me if I'm wrong.</p>

CC BY-SA 3.0
2018-03-10T21:39:16.703Z
2018-03-10T21:39:16.703Z
Mrudav Shukla
<p>I've cloned PIVX(basically a DASH fork) and modified basic parameters. It compiles fine. When I'm trying to run it the server starts and the debug log file shows following errors:</p>

<blockquote>
  <p>ERROR: CheckProofOfWork() : hash doesn't match nBits<br>
  ERROR: CheckBlockHeader() : proof of work failed<br>
  ERROR: CheckBlock() : CheckBlockHeader failed</p>
</blockquote>

<p>To generate my genesis block I've changed the following parameters:</p>

<ul>
<li>pszTimestamp : Used a random latest news.</li>
<li>vAlertPubKey : Used the alert key from generation commands mentioned in <a href="https://pastebin.com/tZuCdC00" rel="nofollow noreferrer">this pastebin link</a>.</li>
<li><p>scriptPubKey : Used the genesis hex from generation commands mentioned in <a href="https://pastebin.com/tZuCdC00" rel="nofollow noreferrer">this pastebin link</a>.</p></li>
<li><p>genesis.nTime : Got the latest unix timestamp.</p></li>
<li>genesis.nNonce : Obtained it from genesis block creation algorithm mentioned in <a href="https://pastebin.com/du2XdxCC" rel="nofollow noreferrer">this pastebin link</a>.</li>
</ul>

<p>I was able to successfully generate new genesis hash as well as merkle root. But after compiling it and I get the above error.</p>

<p>I've tried looking for the solution on the web but most of them had no concrete answers or no answers at all except <a href="https://bitcoin.stackexchange.com/questions/55135/checkproofofwork-linux-error-on-old-altcoins">this one</a>.</p>

<p>It explains that the hash of my genesis block is greater than the target hash which is obtained using <code>nBits</code> variable. So my question is how do I make sure that my genesis hash is less than the target hash to get rid of the errors mentioned?</p>

<bitcoind><altcoin><blockchain-fork><genesis-block><dash>
How to correctly set attributes for block hash and nBits in PIVX Fork?
Mrudav Shukla
# How to correctly set attributes for block hash and nBits in PIVX Fork?

(Asked by: username_0 on 2018-03-09)

I've cloned PIVX(basically a DASH fork) and modified basic parameters. It compiles fine. When I'm trying to run it the server starts and the debug log file shows following errors:

> ERROR: CheckProofOfWork() : hash doesn't match nBits  
> ERROR: CheckBlockHeader() : proof of work failed  
> ERROR: CheckBlock() : CheckBlockHeader failed

To generate my genesis block I've changed the following parameters:

* pszTimestamp : Used a random latest news.
* vAlertPubKey : Used the alert key from generation commands mentioned in [this pastebin link](https://pastebin.com/tZuCdC00).
* scriptPubKey : Used the genesis hex from generation commands mentioned in [this pastebin link](https://pastebin.com/tZuCdC00).
* genesis.nTime : Got the latest unix timestamp.
* genesis.nNonce : Obtained it from genesis block creation algorithm mentioned in [this pastebin link](https://pastebin.com/du2XdxCC).

I was able to successfully generate new genesis hash as well as merkle root. But after compiling it and I get the above error.

I've tried looking for the solution on the web but most of them had no concrete answers or no answers at all except [this one](https://bitcoin.stackexchange.com/questions/55135/checkproofofwork-linux-error-on-old-altcoins).

It explains that the hash of my genesis block is greater than the target hash which is obtained using `nBits` variable. So my question is how do I make sure that my genesis hash is less than the target hash to get rid of the errors mentioned?

**Tags:** bitcoind, altcoin, blockchain-fork, genesis-block, dash


---

## 1 answers

### Answer by username_0 on 2018-03-10. Score: 1 | Accepted answer

I found the answer. However please correct me if there's I'm wrong in explaining this.

Basically, once we have inputs for the block, we hash the data. This hashing can be achieved using multiple techniques viz. SHA256, scrypt, X11, etc.

The issue with generating a hash for the genesis was I used scrypt algorithm to generate the hash. You may come across paste bin links with this method `scrypt_1024_1_1_256_sp_sse2`.

So in my case, I replaced this with the method offered by `uint256` class. You can find this genesis creation logic at [this pastebin](https://pastebin.com/burynTft).

Feel free to add anything or correct me if I'm wrong.


---

