<p>Whatever I do, I am unable to mine the 1st block after the genesis block. All the while, I have assumed that I have mined the Genesis block, and I am unable to mine the 1st block using "setgenerate true" command. But, I may be wrong. I may have NOT actually mined the genesis block. Yes, I have got confused. I have generated new keys. So, here is what I have done from start.</p>

<p>1) Code before genesis block:</p>

<p>In "chainparams.php", I have updated the following.</p>

<pre><code>boost::assign::map_list_of(0, uint256("0x01"));
static const Checkpoints::CCheckpointData data = {
    &amp;mapCheckpoints,
    1538530667, // * UNIX timestamp of last checkpoint block
    0,    // * total number of transactions between genesis and last checkpoint
                //   (the tx=... number in the SetBestChain debug.log lines)
    500        // * estimated number of transactions per day after checkpoint
};
</code></pre>

<hr>

<pre><code>pchMessageStart[0] = 0x91;
pchMessageStart[1] = 0xc5;
pchMessageStart[2] = 0xfa;
pchMessageStart[3] = 0xe3;
vAlertPubKey = ParseHex("04ae6724abca5c2e2e9524d3cd10a303e0ef3f02d324bac4d06aceb873fb8591f1a968d9a2e5ac7024d5a45643d189b99015314d7ef1ff5f8799b9680d6e668471");
</code></pre>

<hr>

<pre><code>const char* pszTimestamp = "my new message here. trying to learn how to create an altcoin.";
txNew.vout[0].nValue = 50 * COIN;
txNew.vout[0].scriptPubKey = CScript() &lt;&lt; ParseHex("047394ed7e750f6202487e7c8ec1e61bbd2fb5cdc6f0f5488af4d2ea082bec606fea95eea381cd0466cf6ea53d8f42c299f9d0e2a3bc313515fc52f02a16fef0a0") &lt;&lt; OP_CHECKSIG;
genesis.nTime = 1538530667;
genesis.nBits = 0x1e0ffff0;

assert(hashGenesisBlock == uint256("0x01"));
assert(genesis.hashMerkleRoot == uint256("0x01"));

fRequireRPCPassword = false;
fMiningRequiresPeers = false;
fAllowMinDifficultyBlocks = false;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = true;
fSkipProofOfWorkCheck = false;
fTestnetToBeDeprecatedFieldRPC = false;
fHeadersFirstSyncingActive = false;
</code></pre>

<hr>

<pre><code>vFixedSeeds.clear();
vSeeds.clear();
</code></pre>

<hr>

<p>In the main.cpp file I changed the following</p>

<pre><code>int64_t nSubsidy = 0;

if(nHeight == 0) {
    nSubsidy = 0;
} else if( .......
</code></pre>

<p>Please note, I have also tried changing nSubsidy value for nHight = 0 to "50 * COIN" and also to higher value like "5000 * COIN". Everything results in the same issue.</p>

<p>2) Used the following code to create the genesis block.</p>

<pre><code>if(genesis.GetHash() != uint256("0x"))
{
      printf("MSearching for genesis block...\n");
      uint256 hashTarget;
      hashTarget.SetCompact(genesis.nBits);
      while(uint256(genesis.GetHash()) &gt; uint256(hashTarget))
      {
          ++genesis.nNonce;
          if (genesis.nNonce == 0)
          {
              printf("Mainnet NONCE WRAPPED, incrementing time");
              std::cout &lt;&lt; std::string("Mainnet NONCE WRAPPED, incrementing time:\n");
              ++genesis.nTime;
          }
          if (genesis.nNonce % 10000 == 0)
          {
              printf("Mainnet: nonce %08u: hash = %s \n", genesis.nNonce, genesis.GetHash().ToString().c_str());
          }
      }
      printf("Mainnet block.nTime = %u \n", genesis.nTime);
      printf("Mainnet block.nNonce = %u \n", genesis.nNonce);
      printf("Mainnet block.hashMerkleRoot: %s\n", genesis.hashMerkleRoot.ToString().c_str());
      printf("Mainnet block.GetHash = %s\n", genesis.GetHash().ToString().c_str());
}
</code></pre>

<p>3) I got the following results.</p>

<pre><code>block.nTime = 1538530667
block.nNonce = 3916247
block.hashMerkleRoot: 668d1e9c1c4f354589b9357d0ac0135b5e236f13ea8cf3bdf79e3670d347e07b
block.GetHash = 00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820
</code></pre>

<p>4) Updated the above info in the file "chainparams.cpp".</p>

<pre><code>boost::assign::map_list_of(0, uint256("00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820"));

genesis.nTime = 1538530667;
genesis.nBits = 0x1e0ffff0;
genesis.nNonce = 3916247;

assert(hashGenesisBlock == uint256("00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820"));
assert(genesis.hashMerkleRoot == uint256("668d1e9c1c4f354589b9357d0ac0135b5e236f13ea8cf3bdf79e3670d347e07b"));
</code></pre>

<p>5) Removed the code that I used to create the genesis block which I used in step 2 (above).</p>

<p>6) Compiled again, no errors or issues.</p>

<p>7) I made this current VPS as server and created a "coin.conf" file and added the following:</p>

<pre><code>server=1
rpcuser=user
rpcpassword=password
listen=1
daemon=1
</code></pre>

<p>8) I did NOT clone this server to create a new client. Instead, I created a new VPS, installed all the dependences and copied the full folder - complete project into that client VPS to setup the client.</p>

<p>9) I added the following in "coin.conf" file in the client VPS.</p>

<pre><code>addnode=&lt;ipaddress of the server&gt; (Ex: 207.87.10.2)
</code></pre>

<p>10) Started the wallet - "coin-qt" on the server. No errors.</p>

<p>11) Started the wallet - "coin-qt" on the client. No errors.</p>

<p>12) Both connected without issues.</p>

<p>13) Ran the following command on the client to mine the 1st block.</p>

<pre><code>setgenerate true
</code></pre>

<p>Got the following error.</p>

<pre><code>"wallet keypool empty"
</code></pre>

<p>stopped setgenerate using</p>

<pre><code>setgenerate false
</code></pre>

<p>14) Executed the following command.</p>

<pre><code>keypoolrefill
</code></pre>

<p>15) Again tried setgenerate</p>

<pre><code>setgenerate true
</code></pre>

<p>16) Checked the debug.log file. This is what I am getting.</p>

<pre><code>CreateNewBlock(): total size 1000
ERROR: CheckProofOfWork() : hash doesn't match nBits
ERROR: CheckBlockHeader() : proof of work failed
ERROR: CheckBlock() : CheckBlockHeader failed
CreateNewBlock() : TestBlockValidity failed
keypool return 2
keypool reserve 2
</code></pre>

<p>I printed the hashes in the debug file. This is what I get.</p>

<pre><code>Hash = 35301222bb9164c21222107e1c43045c50c190d63eb8be2ad193ed38228b26a1
bnTarget = 00000fffff000000000000000000000000000000000000000000000000000000
</code></pre>

<p>I am stuck here. Whatever I do, how many times I start from scratch, I end up here.</p>

<p>Are there any other setting that I have to change related to ProofOfWork? What am I doing wrong? Can someone help me?</p>

CC BY-SA 4.0
2018-11-14T01:02:53.903Z
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
2019-03-03T22:23:37.513Z
Were you able to solve this issue? No proper answer has been given but yet it seems that you have been successful in mining past the genesis block according to your newer question: https://bitcoin.stackexchange.com/questions/79977/how-can-i-simulate-proofofstake-pos-for-a-testnet-clone-of-pivx
Joe Uhren
CC BY-SA 4.0
2019-03-05T01:32:30.913Z
Hello Joe, well, I could not get this working with PIVX fork. I used an other fork which was a fork of PIVX and then, changed false to true for fSkipProofOfWorkCheck = true (this is not the proper way) and get it working. But, I never got this working with keeping fSkipProofOfWorkCheck = false;
Harish Kumar B P
CC BY-SA 4.0
2018-10-04T17:05:05.137Z
I've been hacking away at a PIVX fork as well.
I will try generating a genesis block with your code in my fork tomorrow, and see if I get a different result. We could compare the source code we're using via GitHub.
Do you mind sharing a link?
WG91
<bitcoin-core><bitcoind><altcoin><genesis-block><cpuminer>
Cannot mine Genesis / First Block (PIVX Fork / Clone)
Harish Kumar B P
# Cannot mine Genesis / First Block (PIVX Fork / Clone)

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

Whatever I do, I am unable to mine the 1st block after the genesis block. All the while, I have assumed that I have mined the Genesis block, and I am unable to mine the 1st block using "setgenerate true" command. But, I may be wrong. I may have NOT actually mined the genesis block. Yes, I have got confused. I have generated new keys. So, here is what I have done from start.

1) Code before genesis block:

In "chainparams.php", I have updated the following.

```
boost::assign::map_list_of(0, uint256("0x01"));
static const Checkpoints::CCheckpointData data = {
    &mapCheckpoints,
    1538530667, // * UNIX timestamp of last checkpoint block
    0,    // * total number of transactions between genesis and last checkpoint
                //   (the tx=... number in the SetBestChain debug.log lines)
    500        // * estimated number of transactions per day after checkpoint
};

```

---

```
pchMessageStart[0] = 0x91;
pchMessageStart[1] = 0xc5;
pchMessageStart[2] = 0xfa;
pchMessageStart[3] = 0xe3;
vAlertPubKey = ParseHex("04ae6724abca5c2e2e9524d3cd10a303e0ef3f02d324bac4d06aceb873fb8591f1a968d9a2e5ac7024d5a45643d189b99015314d7ef1ff5f8799b9680d6e668471");

```

---

```
const char* pszTimestamp = "my new message here. trying to learn how to create an altcoin.";
txNew.vout[0].nValue = 50 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("047394ed7e750f6202487e7c8ec1e61bbd2fb5cdc6f0f5488af4d2ea082bec606fea95eea381cd0466cf6ea53d8f42c299f9d0e2a3bc313515fc52f02a16fef0a0") << OP_CHECKSIG;
genesis.nTime = 1538530667;
genesis.nBits = 0x1e0ffff0;

assert(hashGenesisBlock == uint256("0x01"));
assert(genesis.hashMerkleRoot == uint256("0x01"));

fRequireRPCPassword = false;
fMiningRequiresPeers = false;
fAllowMinDifficultyBlocks = false;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = true;
fSkipProofOfWorkCheck = false;
fTestnetToBeDeprecatedFieldRPC = false;
fHeadersFirstSyncingActive = false;

```

---

```
vFixedSeeds.clear();
vSeeds.clear();

```

---

In the main.cpp file I changed the following

```
int64_t nSubsidy = 0;

if(nHeight == 0) {
    nSubsidy = 0;
} else if( .......

```

Please note, I have also tried changing nSubsidy value for nHight = 0 to "50 \* COIN" and also to higher value like "5000 \* COIN". Everything results in the same issue.

2) Used the following code to create the genesis block.

```
if(genesis.GetHash() != uint256("0x"))
{
      printf("MSearching for genesis block...\n");
      uint256 hashTarget;
      hashTarget.SetCompact(genesis.nBits);
      while(uint256(genesis.GetHash()) > uint256(hashTarget))
      {
          ++genesis.nNonce;
          if (genesis.nNonce == 0)
          {
              printf("Mainnet NONCE WRAPPED, incrementing time");
              std::cout << std::string("Mainnet NONCE WRAPPED, incrementing time:\n");
              ++genesis.nTime;
          }
          if (genesis.nNonce % 10000 == 0)
          {
              printf("Mainnet: nonce %08u: hash = %s \n", genesis.nNonce, genesis.GetHash().ToString().c_str());
          }
      }
      printf("Mainnet block.nTime = %u \n", genesis.nTime);
      printf("Mainnet block.nNonce = %u \n", genesis.nNonce);
      printf("Mainnet block.hashMerkleRoot: %s\n", genesis.hashMerkleRoot.ToString().c_str());
      printf("Mainnet block.GetHash = %s\n", genesis.GetHash().ToString().c_str());
}

```

3) I got the following results.

```
block.nTime = 1538530667
block.nNonce = 3916247
block.hashMerkleRoot: 668d1e9c1c4f354589b9357d0ac0135b5e236f13ea8cf3bdf79e3670d347e07b
block.GetHash = 00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820

```

4) Updated the above info in the file "chainparams.cpp".

```
boost::assign::map_list_of(0, uint256("00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820"));

genesis.nTime = 1538530667;
genesis.nBits = 0x1e0ffff0;
genesis.nNonce = 3916247;

assert(hashGenesisBlock == uint256("00000320986bcdf6c2e62f36321232ce1dfc77dc0e0b4a79e2199d8b77fa4820"));
assert(genesis.hashMerkleRoot == uint256("668d1e9c1c4f354589b9357d0ac0135b5e236f13ea8cf3bdf79e3670d347e07b"));

```

5) Removed the code that I used to create the genesis block which I used in step 2 (above).

6) Compiled again, no errors or issues.

7) I made this current VPS as server and created a "coin.conf" file and added the following:

```
server=1
rpcuser=user
rpcpassword=password
listen=1
daemon=1

```

8) I did NOT clone this server to create a new client. Instead, I created a new VPS, installed all the dependences and copied the full folder - complete project into that client VPS to setup the client.

9) I added the following in "coin.conf" file in the client VPS.

```
addnode=<ipaddress of the server> (Ex: 207.87.10.2)

```

10) Started the wallet - "coin-qt" on the server. No errors.

11) Started the wallet - "coin-qt" on the client. No errors.

12) Both connected without issues.

13) Ran the following command on the client to mine the 1st block.

```
setgenerate true

```

Got the following error.

```
"wallet keypool empty"

```

stopped setgenerate using

```
setgenerate false

```

14) Executed the following command.

```
keypoolrefill

```

15) Again tried setgenerate

```
setgenerate true

```

16) Checked the debug.log file. This is what I am getting.

```
CreateNewBlock(): total size 1000
ERROR: CheckProofOfWork() : hash doesn't match nBits
ERROR: CheckBlockHeader() : proof of work failed
ERROR: CheckBlock() : CheckBlockHeader failed
CreateNewBlock() : TestBlockValidity failed
keypool return 2
keypool reserve 2

```

I printed the hashes in the debug file. This is what I get.

```
Hash = 35301222bb9164c21222107e1c43045c50c190d63eb8be2ad193ed38228b26a1
bnTarget = 00000fffff000000000000000000000000000000000000000000000000000000

```

I am stuck here. Whatever I do, how many times I start from scratch, I end up here.

Are there any other setting that I have to change related to ProofOfWork? What am I doing wrong? Can someone help me?

**Tags:** bitcoin-core, bitcoind, altcoin, genesis-block, cpuminer

> **Comments:**
> **username_3**: I've been hacking away at a PIVX fork as well. I will try generating a genesis block with your code in my fork tomorrow, and see if I get a different result. We could compare the source code we're using via GitHub. Do you mind sharing a link?  
> **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**: Were you able to solve this issue? No proper answer has been given but yet it seems that you have been successful in mining past the genesis block according to your newer question: https://bitcoin.stackexchange.com/questions/79977/how-can-i-simulate-proofofstake-pos-for-a-testnet-clone-of-pivx  
> **username_0**: Hello Joe, well, I could not get this working with PIVX fork. I used an other fork which was a fork of PIVX and then, changed false to true for fSkipProofOfWorkCheck = true (this is not the proper way) and get it working. But, I never got this working with keeping fSkipProofOfWorkCheck = false;  

---

## 0 answers

