<p>Create genesis block. Some people get stuck there, it's really easy:</p>

<ul>
<li>find LoadBlockIndex() function, inside, change:

<ul>
<li>paraphrase (pszTimestamp) to any recent news phase.</li>
<li>get the latest unix time (do a google), and put in block.nTime.</li>
<li>set any nNonce (doesn't really matter), 
you can change the time/nonce for testnet too, if you want to use it.</li>
</ul></li>
</ul>

<p>After you are done, save it. Now the genesis block will not match the hash check and merkle root check, it doesn't matter.</p>

<p>The first time you run the compiled code (daemon or qt), it will say "assertion failed". Just exit the program, go to
config dir (under AppData/Roaming), open the debug.log, get the hash after "block.GetHash() = ", copy and paste it to the beginnig of main.cpp, hashGenesisBlock. Also get the merkle root in the same log file, paste it to the ... position in the following code, in LoadBlockIndex()</p>

<pre><code> assert(block.hashMerkleRoot == uint256("0x..."));
</code></pre>

<p>recompile the code, and genesis block created!</p>

<p>BTW, don't forget to change "txNew.vout[0].nValue = " to the coin per block you defined, it doesn't matter to leave as 50, just be consistent with your coin per block (do this before adjust the hash and m-root, otherwise they will be changed again).</p>

<p>check <a href="https://bitcointalk.org/index.php?topic=225690.0" rel="nofollow">https://bitcointalk.org/index.php?topic=225690.0</a> for complete info </p>

CC BY-SA 3.0
2014-01-29T19:45:05.823Z
I changed the `pszTimestamp` , put the last unix time. After I compiled and started to daemon, I'm getting `litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion hash == hashGenesisBlock' failed.
Aborted` , When I check the debug.log, I'm seeing litecoin's original genesis and merkleroot hashes. What I'm doing wrong ?
ZG-RG
CC BY-SA 3.0
2014-02-28T00:57:23.783Z
I tried this but I get `ERROR: CheckProofOfWork() : hash doesn't match nBits` - any ideas?
Claudiu
CC BY-SA 3.0
2018-02-17T05:36:34.707Z
Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?
creator
CC BY-SA 3.0
2014-01-29T04:48:52.250Z
2015-12-24T10:16:29.053Z
2015-12-24T10:16:29.053Z
Khan Shahrukh
<p>If you want to generate our own unique genesis block you should generate and replace at least the following parameters:</p>

<ul>
<li>nTime (the unix time. Your wallet will display the "No block source
available 5 week(s) behind" mentioned if this is 5 weeks old from
now)</li>
<li>pszTimeStamp (the "timestamp" to "justify" no premining has taken
place)</li>
<li>hashMerkleRoot (the merkle root based on the coinbase transaction of
the block)</li>
<li>hashGenesisBlock (the genesis hash itself!)</li>
<li>nNonce (the correct nounce which is incremented when searching for
the hash that satisfies the target (=difficulty))</li>
</ul>

<p>The pubkey in the output transaction script can also be changed to a unique value. However, as the genesis block can't be spent anyway the same pubkey can be used as in e.g. Litecoin. Also the nBits should not be changed if you are planning to create a Litecoin clone.</p>

<p>You can use this script to create the values for a scrypt genesisblock:
<a href="https://github.com/lhartikk/GenesisH0" rel="nofollow">https://github.com/lhartikk/GenesisH0</a></p>

CC BY-SA 3.0
2017-10-25T18:33:12.970Z
how long it takes on average to get it generated? hours? days? weeks? months> or even more ?
m1k3y3
CC BY-SA 3.0
2018-02-17T05:36:51.243Z
Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?
creator
CC BY-SA 3.0
2014-03-14T14:13:39.610Z
2014-03-14T14:13:39.610Z
lhartikk
<p>I created my genesis using this code, but you need to commment all the assertions in chainparams.cpp:</p>
<pre><code>arith_uint256 best = arith_uint256();
int n=0;
arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits);
while (UintToArith256(genesis.GetHash()) &gt; hashTarget) {
  arith_uint256 c=UintToArith256(genesis.GetHash());
                 
  if(c &lt; best || n==0)
    {
      best = c;
      n=1;
      printf(&quot;%s %s %s\n&quot;,genesis.GetHash().GetHex().c_str(),hashTarget.GetHex().c_str(),
         best.GetHex().c_str());
    }
  
  ++genesis.nNonce;
  if (genesis.nNonce == 0) { ++genesis.nTime; }
}
printf(&quot;%s\n&quot;,genesis.ToString().c_str());
</code></pre>

CC BY-SA 4.0
2021-02-25T01:44:38.583Z
2021-02-25T18:28:32.957Z
2021-02-25T18:28:32.957Z
zBl4ckUSer
<p>I don't see the code where you actually change the <code>block</code> object's hash. The method <code>hashGenesisBlock()</code> returns a hash, but it's never passed to the <code>block</code> object.</p>

<p>Besides, the first line of your code also has a bug: the current time is <code>1390959227</code>, not <code>1390948469</code>. This might also cause a problem.</p>

CC BY-SA 3.0
2018-02-17T05:37:16.277Z
Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?
creator
CC BY-SA 3.0
2014-01-29T01:34:29.090Z
2014-01-29T01:34:29.090Z
Steven Roose
<p>I'm trying to create a testcoin using litecoin. To create genesis block I changed some lines to :</p>

<pre><code>block.nTime = 1390948469; // current time

uint256 hashGenesisBlock("0x"); //I dont now it's true or false

uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x")); //I dont now it's true or false.
        block.print();
        assert(hash == hashGenesisBlock);
</code></pre>

<p>When I build daemon and launch it, I'm getting this error:</p>

<pre><code>litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion `hash == hashGenesisBlock' failed.
Aborted
</code></pre>

<p>When I check the <code>./litecoin debug.log</code> file, I'm seeing the <em>previous</em> hashMerkleRoot and hashGenesisBlock that litecoin uses now. I can't create new hash and merkle root.</p>

<litecoin><altcoin-development><genesis-block>
How can I create a new Genesis Block?
ZG-RG
# How can I create a new Genesis Block?

(Asked by: username_0 on 2014-01-28)

I'm trying to create a testcoin using litecoin. To create genesis block I changed some lines to :

```
block.nTime = 1390948469; // current time

uint256 hashGenesisBlock("0x"); //I dont now it's true or false

uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x")); //I dont now it's true or false.
        block.print();
        assert(hash == hashGenesisBlock);

```

When I build daemon and launch it, I'm getting this error:

```
litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion `hash == hashGenesisBlock' failed.
Aborted

```

When I check the `./litecoin debug.log` file, I'm seeing the *previous* hashMerkleRoot and hashGenesisBlock that litecoin uses now. I can't create new hash and merkle root.

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


---

## 4 answers

### Answer by username_1 on 2014-01-29. Score: 3

Create genesis block. Some people get stuck there, it's really easy:

* find LoadBlockIndex() function, inside, change:
  + paraphrase (pszTimestamp) to any recent news phase.
  + get the latest unix time (do a google), and put in block.nTime.
  + set any nNonce (doesn't really matter),
    you can change the time/nonce for testnet too, if you want to use it.

After you are done, save it. Now the genesis block will not match the hash check and merkle root check, it doesn't matter.

The first time you run the compiled code (daemon or qt), it will say "assertion failed". Just exit the program, go to
config dir (under AppData/Roaming), open the debug.log, get the hash after "block.GetHash() = ", copy and paste it to the beginnig of main.cpp, hashGenesisBlock. Also get the merkle root in the same log file, paste it to the ... position in the following code, in LoadBlockIndex()

```
 assert(block.hashMerkleRoot == uint256("0x..."));

```

recompile the code, and genesis block created!

BTW, don't forget to change "txNew.vout[0].nValue = " to the coin per block you defined, it doesn't matter to leave as 50, just be consistent with your coin per block (do this before adjust the hash and m-root, otherwise they will be changed again).

check <https://bitcointalk.org/index.php?topic=225690.0> for complete info

> **Comments:**
> **username_0**: I changed the `pszTimestamp` , put the last unix time. After I compiled and started to daemon, I'm getting `litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion hash == hashGenesisBlock' failed. Aborted` , When I check the debug.log, I'm seeing litecoin's original genesis and merkleroot hashes. What I'm doing wrong ?  
> **username_2**: I tried this but I get `ERROR: CheckProofOfWork() : hash doesn't match nBits` - any ideas?  
> **username_3**: Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?  

---

### Answer by username_4 on 2014-03-14. Score: 1

If you want to generate our own unique genesis block you should generate and replace at least the following parameters:

* nTime (the unix time. Your wallet will display the "No block source
  available 5 week(s) behind" mentioned if this is 5 weeks old from
  now)
* pszTimeStamp (the "timestamp" to "justify" no premining has taken
  place)
* hashMerkleRoot (the merkle root based on the coinbase transaction of
  the block)
* hashGenesisBlock (the genesis hash itself!)
* nNonce (the correct nounce which is incremented when searching for
  the hash that satisfies the target (=difficulty))

The pubkey in the output transaction script can also be changed to a unique value. However, as the genesis block can't be spent anyway the same pubkey can be used as in e.g. Litecoin. Also the nBits should not be changed if you are planning to create a Litecoin clone.

You can use this script to create the values for a scrypt genesisblock:
<https://github.com/username_4/GenesisH0>

> **Comments:**
> **username_5**: how long it takes on average to get it generated? hours? days? weeks? months> or even more ?  
> **username_3**: Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?  

---

### Answer by username_6 on 2021-02-25. Score: 0

I created my genesis using this code, but you need to commment all the assertions in chainparams.cpp:

```
arith_uint256 best = arith_uint256();
int n=0;
arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits);
while (UintToArith256(genesis.GetHash()) > hashTarget) {
  arith_uint256 c=UintToArith256(genesis.GetHash());
                 
  if(c < best || n==0)
    {
      best = c;
      n=1;
      printf("%s %s %s\n",genesis.GetHash().GetHex().c_str(),hashTarget.GetHex().c_str(),
         best.GetHex().c_str());
    }
  
  ++genesis.nNonce;
  if (genesis.nNonce == 0) { ++genesis.nTime; }
}
printf("%s\n",genesis.ToString().c_str());

```


---

### Answer by username_7 on 2014-01-29. Score: 0

I don't see the code where you actually change the `block` object's hash. The method `hashGenesisBlock()` returns a hash, but it's never passed to the `block` object.

Besides, the first line of your code also has a bug: the current time is `1390959227`, not `1390948469`. This might also cause a problem.

> **Comments:**
> **username_3**: Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently?  

---

