<p>This is because you didn't mine the block, i.e. you didn't search for a nonce that results in a block hash less than <code>powLimit</code> (the initial difficulty target) defined in <code>src/chainparams.cpp</code> <code>consensus.powLimit("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")</code>, for mainnet. To do this:</p>

<p>Serialize the block header. Concatenate (in this order, little endian, hex format) the version, previous block hash, merkle root, unix epoch time, difficulty target (bits), and nonce. Then calculate the HASH256 or the SHA256(SHA256()). If it is not less than <code>powLimit</code> you must change the nonce and try again, keep doing this until you are successful, this is mining.</p>

<p>There are scripts out there to do this, for example: <a href="https://github.com/liveblockchain/genesisgen" rel="nofollow noreferrer">https://github.com/liveblockchain/genesisgen</a></p>

<p><strong>Update (example from question above):</strong></p>

<p>Example usage of <code>genesisgen</code></p>

<pre><code>./genesis [options] &lt;pubkey&gt; "&lt;timestamp&gt;" &lt;nBits&gt; &lt;startNonce&gt; &lt;unixtime&gt;

./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605

    nBits: 0x1d00ffff
    startNonce: 2083236893
    unixtime: 1541690605

    Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573

    PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

    Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d
    Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494
    Generating block...
    124397 Hashes/s, Nonce 20632283897
    Block found!
    Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672
    Nonce: 2063257030
    Unix time: 1541690608
</code></pre>

<p>You need to use the Byteswapped merkle root and the block hash in the assertions and the newly found nonce in the genesis block creation functions.</p>

CC BY-SA 4.0
2018-11-08T15:13:12.600Z
Thanks for your answer. I will try and let you know
Novice Programmer
CC BY-SA 4.0
2018-11-08T15:16:54.407Z
The genesisgen example has two nonce: `startNonce` and `Nonce` which should i use in my program
Novice Programmer
CC BY-SA 4.0
2018-11-08T15:23:02.327Z
You can just use 0 as the start nonce, unless you already know the nonce :)
JBaczuk
CC BY-SA 4.0
2018-11-09T02:34:33.827Z
It does not work . i got me assetion error. i have updated my question . please check
Novice Programmer
CC BY-SA 4.0
2018-11-09T02:46:06.310Z
I believe the merkleroot is wrong endianess, try using the `Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494`
JBaczuk
CC BY-SA 4.0
2018-11-09T15:12:43.820Z
Thanks it works . I was able to generate genesis block without any issue :)
Novice Programmer
CC BY-SA 4.0
2018-11-09T15:14:08.690Z
Also please update your answer
Novice Programmer
CC BY-SA 4.0
2018-11-08T14:56:33.803Z
2018-11-09T15:31:39.910Z
2018-11-09T15:31:39.910Z
JBaczuk
<p>I followed this medium link to create a coin just like bitcoin . <a href="https://medium.com/@jordan.baczuk/how-to-fork-bitcoin-c39139506443" rel="nofollow noreferrer">https://medium.com/@jordan.baczuk/how-to-fork-bitcoin-c39139506443</a></p>

<p>Based on this tutorial i update <code>DEFAULT_MAX_TIP_AGE</code> to <code>int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE * 4000;</code> but it does not work, i did not able to mine block but when i add <code>-maxtipage=432000000</code> to my command line daemon then mining work i was able to mine genesis block . but then i thought it would be better if i can create my own geneisis block.</p>

<p>so i followed this link : <a href="https://bitcoin.stackexchange.com/questions/21303/how-can-i-create-a-new-genesis-block">How can I create a new Genesis Block?</a></p>

<p>I made changes to <code>pszTimestamp</code>, <code>nTime</code> and <code>nNonce</code> , <code>hashGenesisBlock</code> and <code>hashMerkleRoot</code>.</p>

<p>I was able to run the daemon without any <code>assert</code> issue . First i got this error</p>

<blockquote>
  <p>ERROR: ReadBlockFromDisk: Errors in block header at
  CBlockDiskPos(nFile=0, nPos=8) 2018-11-08T10:12:47Z *** Failed to read
  block</p>
</blockquote>

<p>Then after running command line daemon with <code>-reindex</code> . the previous error vanishes but got a new error </p>

<blockquote>
  <p>ERROR: AcceptBlock: high-hash, proof of work failed (code 16)</p>
</blockquote>

<p>How can i resolve this issue </p>

<p><strong>EDIT:</strong>
Based on the suggestion given by @JBaczuk . I used genesisgen to generate block information</p>

<p><a href="https://github.com/liveblockchain/genesisgen" rel="nofollow noreferrer">https://github.com/liveblockchain/genesisgen</a></p>

<p>CMD Syntax:</p>

<pre><code>./genesis [options] &lt;pubkey&gt; "&lt;timestamp&gt;" &lt;nBits&gt; &lt;startNonce&gt; &lt;unixtime&gt;
</code></pre>

<p>My CMD:</p>

<pre><code>./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605
</code></pre>

<p>OUTPUT:</p>

<pre><code>nBits: 0x1d00ffff
startNonce: 2083236893
unixtime: 1541690605

Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573

PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d
Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494
Generating block...
124397 Hashes/s, Nonce 20632283897
Block found!
Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672
Nonce: 2063257030
Unix time: 1541690608
</code></pre>

<p>Changes in code:</p>

<pre><code>static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount&amp; genesisReward)
{
    const char* pszTimestamp = "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches";
    const CScript genesisOutputScript = CScript() &lt;&lt; ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") &lt;&lt; OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
</code></pre>

<p>......
......
......</p>

<pre><code>genesis = CreateGenesisBlock(1541690608, 2063257030, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672"));
assert(genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d"));
</code></pre>

<p>I got this assertion error:</p>

<pre><code>chainparams.cpp:125: CMainParams::CMainParams(): Assertion `genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d")' failed.
Aborted (core dumped)
</code></pre>

CC BY-SA 4.0
2018-11-09T02:36:51.083Z
Downvoted. We have many questions regarding programming issues when creating a new altcoin. I don't believe such questions benefit a general audience, and this is a Q&A site, not a place for support. Furthermore, as a learning experience, contributing to an existing project is far more valuable.
Pieter Wuille
CC BY-SA 4.0
2018-11-09T02:43:06.353Z
There obviously is an audience, since there are many questions, but is stackoverflow the place for these? I have no preference, I just wonder what to suggest for help.
JBaczuk
CC BY-SA 4.0
2018-11-09T06:07:25.003Z
@PieterWuille . Inorder to contribute to existing project . i have to learn how things work in code level so i did little changes to existing bitcoin code and trying to understand  the concept.
Novice Programmer
CC BY-SA 4.0
2023-09-22T01:39:42.467Z
These questions are helpful to others @PieterWuille
david2278
<altcoin><altcoin-development><genesis-block>
ERROR: AcceptBlock: high-hash, proof of work failed (code 16)
Novice Programmer
# ERROR: AcceptBlock: high-hash, proof of work failed (code 16)

(Asked by: username_0 on 2018-11-08)

I followed this medium link to create a coin just like bitcoin . <https://medium.com/@jordan.baczuk/how-to-fork-bitcoin-c39139506443>

Based on this tutorial i update `DEFAULT_MAX_TIP_AGE` to `int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE * 4000;` but it does not work, i did not able to mine block but when i add `-maxtipage=432000000` to my command line daemon then mining work i was able to mine genesis block . but then i thought it would be better if i can create my own geneisis block.

so i followed this link : [How can I create a new Genesis Block?](https://bitcoin.stackexchange.com/questions/21303/how-can-i-create-a-new-genesis-block)

I made changes to `pszTimestamp`, `nTime` and `nNonce` , `hashGenesisBlock` and `hashMerkleRoot`.

I was able to run the daemon without any `assert` issue . First i got this error

> ERROR: ReadBlockFromDisk: Errors in block header at
> CBlockDiskPos(nFile=0, nPos=8) 2018-11-08T10:12:47Z \*\*\* Failed to read
> block

Then after running command line daemon with `-reindex` . the previous error vanishes but got a new error

> ERROR: AcceptBlock: high-hash, proof of work failed (code 16)

How can i resolve this issue

**EDIT:**
Based on the suggestion given by @username_2 . I used genesisgen to generate block information

<https://github.com/liveblockchain/genesisgen>

CMD Syntax:

```
./genesis [options] <pubkey> "<timestamp>" <nBits> <startNonce> <unixtime>

```

My CMD:

```
./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605

```

OUTPUT:

```
nBits: 0x1d00ffff
startNonce: 2083236893
unixtime: 1541690605

Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573

PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d
Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494
Generating block...
124397 Hashes/s, Nonce 20632283897
Block found!
Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672
Nonce: 2063257030
Unix time: 1541690608

```

Changes in code:

```
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches";
    const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

```

......
......
......

```
genesis = CreateGenesisBlock(1541690608, 2063257030, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672"));
assert(genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d"));

```

I got this assertion error:

```
chainparams.cpp:125: CMainParams::CMainParams(): Assertion `genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d")' failed.
Aborted (core dumped)

```

**Tags:** altcoin, altcoin-development, genesis-block

> **Comments:**
> **username_1**: Downvoted. We have many questions regarding programming issues when creating a new altcoin. I don't believe such questions benefit a general audience, and this is a Q&A site, not a place for support. Furthermore, as a learning experience, contributing to an existing project is far more valuable.  
> **username_2**: There obviously is an audience, since there are many questions, but is stackoverflow the place for these? I have no preference, I just wonder what to suggest for help.  
> **username_0**: @username_1 . Inorder to contribute to existing project . i have to learn how things work in code level so i did little changes to existing bitcoin code and trying to understand  the concept.  
> **username_3**: These questions are helpful to others @username_1  

---

## 1 answers

### Answer by username_2 on 2018-11-08. Score: 1 | Accepted answer

This is because you didn't mine the block, i.e. you didn't search for a nonce that results in a block hash less than `powLimit` (the initial difficulty target) defined in `src/chainparams.cpp` `consensus.powLimit("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")`, for mainnet. To do this:

Serialize the block header. Concatenate (in this order, little endian, hex format) the version, previous block hash, merkle root, unix epoch time, difficulty target (bits), and nonce. Then calculate the HASH256 or the SHA256(SHA256()). If it is not less than `powLimit` you must change the nonce and try again, keep doing this until you are successful, this is mining.

There are scripts out there to do this, for example: <https://github.com/liveblockchain/genesisgen>

**Update (example from question above):**

Example usage of `genesisgen`

```
./genesis [options] <pubkey> "<timestamp>" <nBits> <startNonce> <unixtime>

./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605

    nBits: 0x1d00ffff
    startNonce: 2083236893
    unixtime: 1541690605

    Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573

    PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

    Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d
    Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494
    Generating block...
    124397 Hashes/s, Nonce 20632283897
    Block found!
    Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672
    Nonce: 2063257030
    Unix time: 1541690608

```

You need to use the Byteswapped merkle root and the block hash in the assertions and the newly found nonce in the genesis block creation functions.

> **Comments:**
> **username_0**: Thanks for your answer. I will try and let you know  
> **username_0**: The genesisgen example has two nonce: `startNonce` and `Nonce` which should i use in my program  
> **username_2**: You can just use 0 as the start nonce, unless you already know the nonce :)  
> **username_0**: It does not work . i got me assetion error. i have updated my question . please check  
> **username_2**: I believe the merkleroot is wrong endianess, try using the `Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494`  
> **username_0**: Thanks it works . I was able to generate genesis block without any issue :)  
> **username_0**: Also please update your answer  

---

