Author

Topic: Successfully cloned and compiled POW/POS coin but how to pre-mine a coin? (Read 270 times)

jr. member
Activity: 116
Merit: 8
Thanks for sharing the screenshot. I am away from my PC now, so probably by tomorrow we may figure out a way to check these so that the coins are sent through to the wallet.

When the coins are generated, do I have to tell it to send it to the wallet address?
Yes you should. Coinbase transactions are included in the block and they are the ones that pays off the miners during the new generation of coins. ATM I am not able to find the code for coinbase tx, but they are the ones that use the scriptPubKey to identify the miner address. I guess you should be wrong somewhere while compiling or editing the code. Meanwhile you need to have a good understanding of how bitcoin and blockchain works, and for that try giving a read of Mastering Bitcoin Book which is present in the git for free.

Would it not be in the debug.log file or are you referring to the the code in main.cpp:

txNew.vout[0].scriptPubKey = CScript()<< ParseHex(“genesiscoinbase”);

I do have the genesiscoinbase.hex file which contains the public and private keys.
legendary
Activity: 1584
Merit: 1280
Heisenberg Design Services
Thanks for sharing the screenshot. I am away from my PC now, so probably by tomorrow we may figure out a way to check these so that the coins are sent through to the wallet.

When the coins are generated, do I have to tell it to send it to the wallet address?
Yes you should. Coinbase transactions are included in the block and they are the ones that pays off the miners during the new generation of coins. ATM I am not able to find the code for coinbase tx, but they are the ones that use the scriptPubKey to identify the miner address. I guess you should be wrong somewhere while compiling or editing the code. Meanwhile you need to have a good understanding of how bitcoin and blockchain works, and for that try giving a read of Mastering Bitcoin Book which is present in the git for free.
jr. member
Activity: 116
Merit: 8
I did went to check the Peercoin source and what you have explained above on Line #967 shows a totally different function.  Should I change the code to match what you have above?  I have also found another example coin using the same source code; however, the GetProofOfWorkReword function shows less compared to Compound Coin.  It is called 404coin.  
I need to know that is your alt coin capped or uncapped! Since Bitcoin is capped and the code which I have mentioned is based on that. If the coin is capped you need to clone the bitcoin code else if your coin is uncapped use the peercoin code. The function between what I have mentioned and what you have seen in the code is completely different because peercoin has an uncapped supply and it will emit the coins as long as the blocks are solved by the miners. Since bitcoin is capped, the halving takes place resulting in the decreasing of coins per 21000 blocks. I am unaware of how peercoin works, but I am giving out these suggestions to you completely based on bitcoin. I am aware of only bitcoin code and a little bit of ethereum along with smart contracts.

Also you need to note that I have far minimum knowledge on PoS coins and their coding mechanism. If you consider the peercoin code which has an uncapped supply and works on Proof of Stake mechanism, this code emits the coins when miner solves the block...

Code:
int64 GetProofOfStakeReward(int64 nCoinAge)
{
    static int64 nRewardCoinYear = CENT;  // creation amount per coin-year
    int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
    if (fDebug && GetBoolArg("-printcreation"))
        printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge);
    return nSubsidy;
}

But to actually mine the coins, am I correct in the methods that I asked (i.e. using 2 daemons or running 2 wallet gui where one is the server and the other the client) or do I need to use a miner?  There should be an internal miner to test in seeing how to generate the coins.
You don't need to use a separate miner since you are finding the blocks at a lower difficulty. Once the difficulty rises, you need to shift yourself to higher processing units.

P.S You could have cloned bitcoin instead and could have directed your questions to the development and tech board of this forum. It is being visited by many devs and you could create your alt more easily. Altcoin Discussion board is shit and is clogged up with spammers who have no knowledge on anything and I might be the only one to help you in this situation  Undecided

I really do appreciate your help and I believe you are the only one where I am slowly understanding blockchain technology.  I wish I could move this whole thread to the project development section.

The problem with cloning Bitcoin is that it is strictly proof of work and I would like to create a hybrid POW/POS coin which the current code is based on.  By the way I made changes to the section where you were confused on section of the code for the block height.

I will provide more details, code snippets and output when I run the wallet.  When I ran the qt wallet yesterday on testnet to look at the getinfo and getmining info, I saw that it generated 1000 blocks.  When I looked at the Block Explorer within the wallet it confirmed that 1000 coins were created and 15 for the fee.  As I kept on looking at the blocks by typing getmininginfo it still remained 0.  When the coins are generated, do I have to tell it to send it to the wallet address?  This is not the same as when I compiled the Litecoin clone where when I set the setgenerate to true that it showed the mined coins in the wallet.

So below is the code that I changed for the nSubsidy:

Code:
// miner's coin base reward
int64_t GetProofOfWorkReward(int64_t nFees)
{
    int64_t nSubsidy = 0 * COIN;
    
 if (pindexBest->nHeight < 1000)
    {
      nSubsidy = 100000 * COIN;
      return nSubsidy + nFees;
}

    if (fDebug && GetBoolArg("-printcreation"))
        printf("GetProofOfWorkReward() : create=%s nSubsidy=%"PRId64"\n", FormatMoney(nSubsidy).c_str(), nSubsidy);

    return nSubsidy + nFees;
}

These are the getinfo and getmininginfo output from a server and client wallet running:

"version" : "v1.3.0.0",
"protocolversion" : 60014,
"walletversion" : 60000,
"balance" : 0.00000000,
"newmint" : 0.00000000,
"stake" : 0.00000000,
"split threshold" : 50.00000000,
"combine threshold" : 500.00000000,
"blocks" : 0,
"timeoffset" : 0,
"moneysupply" : 0.00000000,
"connections" : 1,
"proxy" : "",
"ip" : "0.0.0.0",
"difficulty" : {
"proof-of-work" : 0.00024414,
"proof-of-stake" : 0.00024414
},
"testnet" : true,
"keypoololdest" : 1550720968,
"keypoolsize" : 101,
"paytxfee" : 0.00000000,
"mininput" : 0.00000000,
"errors" : ""



"blocks" : 0,
"currentblocksize" : 1000,
"currentblocktx" : 0,
"difficulty" : {
"proof-of-work" : 0.00024414,
"proof-of-stake" : 0.00024414,
"search-interval" : 1
},
"blockvalue" : 1000000000000,
"netmhashps" : 0.03495203,
"netstakeweight" : 0.00000000,
"errors" : "",
"pooledtx" : 0,
"stakeweight" : {
"minimum" : 0,
"maximum" : 0,
"combined" : 0
},
"stakeinterest" : 250000000,
"testnet" : true

and below is a screenshot of the wallet block explorer:

https://files.fm/u/32b9x2va
jr. member
Activity: 116
Merit: 8
I did went to check the Peercoin source and what you have explained above on Line #967 shows a totally different function.  Should I change the code to match what you have above?  I have also found another example coin using the same source code; however, the GetProofOfWorkReword function shows less compared to Compound Coin.  It is called 404coin. 
I need to know that is your alt coin capped or uncapped! Since Bitcoin is capped and the code which I have mentioned is based on that. If the coin is capped you need to clone the bitcoin code else if your coin is uncapped use the peercoin code. The function between what I have mentioned and what you have seen in the code is completely different because peercoin has an uncapped supply and it will emit the coins as long as the blocks are solved by the miners. Since bitcoin is capped, the halving takes place resulting in the decreasing of coins per 21000 blocks. I am unaware of how peercoin works, but I am giving out these suggestions to you completely based on bitcoin. I am aware of only bitcoin code and a little bit of ethereum along with smart contracts.

Also you need to note that I have far minimum knowledge on PoS coins and their coding mechanism. If you consider the peercoin code which has an uncapped supply and works on Proof of Stake mechanism, this code emits the coins when miner solves the block...

Code:
int64 GetProofOfStakeReward(int64 nCoinAge)
{
    static int64 nRewardCoinYear = CENT;  // creation amount per coin-year
    int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
    if (fDebug && GetBoolArg("-printcreation"))
        printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge);
    return nSubsidy;
}

But to actually mine the coins, am I correct in the methods that I asked (i.e. using 2 daemons or running 2 wallet gui where one is the server and the other the client) or do I need to use a miner?  There should be an internal miner to test in seeing how to generate the coins.
You don't need to use a separate miner since you are finding the blocks at a lower difficulty. Once the difficulty rises, you need to shift yourself to higher processing units.

P.S You could have cloned bitcoin instead and could have directed your questions to the development and tech board of this forum. It is being visited by many devs and you could create your alt more easily. Altcoin Discussion board is shit and is clogged up with spammers who have no knowledge on anything and I might be the only one to help you in this situation  Undecided

I really do appreciate your help and I believe you are the only one where I am slowly understanding blockchain technology.  I wish I could move this whole thread to the project development section.

The problem with cloning Bitcoin is that it is strictly proof of work and I would like to create a hybrid POW/POS coin which the current code is based on.  By the way I made changes to the section where you were confused on section of the code for the block height.

I will provide more details, code snippets and output when I run the wallet.  When I ran the qt wallet yesterday on testnet to look at the getinfo and getmining info, I saw that it generated 1000 blocks.  When I looked at the Block Explorer within the wallet it confirmed that 1000 coins were created and 15 for the fee.  As I kept on looking at the blocks by typing getmininginfo it still remained 0.  When the coins are generated, do I have to tell it to send it to the wallet address?  This is not the same as when I compiled the Litecoin clone where when I set the setgenerate to true that it showed the mined coins in the wallet.
legendary
Activity: 1584
Merit: 1280
Heisenberg Design Services
I did went to check the Peercoin source and what you have explained above on Line #967 shows a totally different function.  Should I change the code to match what you have above?  I have also found another example coin using the same source code; however, the GetProofOfWorkReword function shows less compared to Compound Coin.  It is called 404coin. 
I need to know that is your alt coin capped or uncapped! Since Bitcoin is capped and the code which I have mentioned is based on that. If the coin is capped you need to clone the bitcoin code else if your coin is uncapped use the peercoin code. The function between what I have mentioned and what you have seen in the code is completely different because peercoin has an uncapped supply and it will emit the coins as long as the blocks are solved by the miners. Since bitcoin is capped, the halving takes place resulting in the decreasing of coins per 21000 blocks. I am unaware of how peercoin works, but I am giving out these suggestions to you completely based on bitcoin. I am aware of only bitcoin code and a little bit of ethereum along with smart contracts.

Also you need to note that I have far minimum knowledge on PoS coins and their coding mechanism. If you consider the peercoin code which has an uncapped supply and works on Proof of Stake mechanism, this code emits the coins when miner solves the block...

Code:
int64 GetProofOfStakeReward(int64 nCoinAge)
{
    static int64 nRewardCoinYear = CENT;  // creation amount per coin-year
    int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
    if (fDebug && GetBoolArg("-printcreation"))
        printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge);
    return nSubsidy;
}

But to actually mine the coins, am I correct in the methods that I asked (i.e. using 2 daemons or running 2 wallet gui where one is the server and the other the client) or do I need to use a miner?  There should be an internal miner to test in seeing how to generate the coins.
You don't need to use a separate miner since you are finding the blocks at a lower difficulty. Once the difficulty rises, you need to shift yourself to higher processing units.

P.S You could have cloned bitcoin instead and could have directed your questions to the development and tech board of this forum. It is being visited by many devs and you could create your alt more easily. Altcoin Discussion board is shit and is clogged up with spammers who have no knowledge on anything and I might be the only one to help you in this situation  Undecided
jr. member
Activity: 116
Merit: 8
Below is my project files:
https://github.com/skourdes/Compound-Coin

For the premine to be done, would that be in the checkpoints.cpp file?
Thanks for pointing me to your code so that it could be easier to explain the concepts. As far as I have seen, the so called compound coin seems to be based on the satoshi client a little. Here in the code, the subsidy values are mentioned starting from Line#967. Also your code seems to be pretty broken up,

For example if you consider the above bitcoin code which I have posted, it has been clearly mentioned the coins are cut into 2 after the halving takes place. Whereas in your code, there would be 94958891.757693062 coins generated if the block height is less than 25 and 1 coin would be generated if the block height is less than 1000 and 100 coins would be generated if the height is less than 50000.  Huh
I am totally confused with your code man.

After reading through PeerCoin a little, they don't seem to have a capped supply to prevent inflation and also they follow both the POW and POS algorithm. I have very little knowledge of POS code hence I won't be able to guide you through that.

P.S Checkpoints are used to prevent the hashing of block in lower difficulty. Since you are premining them in first or second block there is no need to change the code in checkpoints. They are probably used for future prevention of 51% attack in the network. Check out my explanation for checkpoints here :  What is use of Checkpoints in a cryptocurrency?

Is that you who have posted this same topic in bitcoin stackexchange? If so, that is wrong area to post that and you probably won't be answered since that doesn't belong to bitcoin and you are cloning an altcoin.

Actually, this is the code based on Compound Coin and did not write the GetProofOfWorkReward function.  I did went to check the Peercoin source and what you have explained above on Line #967 shows a totally different function.  Should I change the code to match what you have above?  I have also found another example coin using the same source code; however, the GetProofOfWorkReword function shows less compared to Compound Coin.  It is called 404coin. 

https://github.com/michnkeks/404-Coin

But to actually mine the coins, am I correct in the methods that I asked (i.e. using 2 daemons or running 2 wallet gui where one is the server and the other the client) or do I need to use a miner?  There should be an internal miner to test in seeing how to generate the coins.
legendary
Activity: 1584
Merit: 1280
Heisenberg Design Services
Below is my project files:
https://github.com/skourdes/Compound-Coin

For the premine to be done, would that be in the checkpoints.cpp file?
Thanks for pointing me to your code so that it could be easier to explain the concepts. As far as I have seen, the so called compound coin seems to be based on the satoshi client a little. Here in the code, the subsidy values are mentioned starting from Line#967. Also your code seems to be pretty broken up,

For example if you consider the above bitcoin code which I have posted, it has been clearly mentioned the coins are cut into 2 after the halving takes place. Whereas in your code, there would be 94958891.757693062 coins generated if the block height is less than 25 and 1 coin would be generated if the block height is less than 1000 and 100 coins would be generated if the height is less than 50000.  Huh
I am totally confused with your code man.

After reading through PeerCoin a little, they don't seem to have a capped supply to prevent inflation and also they follow both the POW and POS algorithm. I have very little knowledge of POS code hence I won't be able to guide you through that.

P.S Checkpoints are used to prevent the hashing of block in lower difficulty. Since you are premining them in first or second block there is no need to change the code in checkpoints. They are probably used for future prevention of 51% attack in the network. Check out my explanation for checkpoints here :  What is use of Checkpoints in a cryptocurrency?

Is that you who have posted this same topic in bitcoin stackexchange? If so, that is wrong area to post that and you probably won't be answered since that doesn't belong to bitcoin and you are cloning an altcoin.
jr. member
Activity: 116
Merit: 8
It is only how the coins are generated where I am still trying to understand.
This is not a secret project to talk through PM, if we have successfully cloned the coin and premined them, this topic might serve someone who is looking through the same in future. I don't have much idea on how Peercoin works, but I have read that they do share the same code as bitcoin with minor changes.

I have cloned bitcoin once, and with the older version of bitcoin-qt client the coin generation probably takes place in the main.cpp code of the bitcoin. But with the newer versions coming into picture, this main.cpp of the older client has been split into net_processing.cpp and validation.cpp. If your compound coin code has main.cpp check for the GetBlockSubsidy method in it. Otherwise they would be present in validation.cpp of the code. The code would look like

Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

We need to consider that there are totally 100,000,000 satoshis in one bitcoin. Hence at the start of the code, 50 is multiplied with this 100,000,000 satoshis which yields 50 bitcoins in total as the initial Subsidy. Once 210,000 blocks are mined the subsidy is cut in half since nHeight is the total block height. When the 64 halvings are reached in total the code returns only 0. So after 64 halving period the miner receives only fees.

Hi,

That is where I am having the issues is that it does not indicate anything being premined; thus, no coins being generated.

I went to check the code snippet and could not find it on the main.cpp file.  I am sure there has been modifications done throughout the previous clone.

Below is my project files:
https://github.com/skourdes/Compound-Coin

Mine is forked from Compound-Coin and there are modifications based on my coin.
For the premine to be done, would that be in the checkpoints.cpp file?
legendary
Activity: 1584
Merit: 1280
Heisenberg Design Services
It is only how the coins are generated where I am still trying to understand.
This is not a secret project to talk through PM, if we have successfully cloned the coin and premined them, this topic might serve someone who is looking through the same in future. I don't have much idea on how Peercoin works, but I have read that they do share the same code as bitcoin with minor changes.

I have cloned bitcoin once, and with the older version of bitcoin-qt client the coin generation probably takes place in the main.cpp code of the bitcoin. But with the newer versions coming into picture, this main.cpp of the older client has been split into net_processing.cpp and validation.cpp. If your compound coin code has main.cpp check for the GetBlockSubsidy method in it. Otherwise they would be present in validation.cpp of the code. The code would look like

Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

We need to consider that there are totally 100,000,000 satoshis in one bitcoin. Hence at the start of the code, 50 is multiplied with this 100,000,000 satoshis which yields 50 bitcoins in total as the initial Subsidy. Once 210,000 blocks are mined the subsidy is cut in half since nHeight is the total block height. When the 64 halvings are reached in total the code returns only 0. So after 64 halving period the miner receives only fees.
member
Activity: 392
Merit: 66
It is only how the coins are generated where I am still trying to understand.  From your response, this adds more knowledge in setting the difficulty in generating blocks.
You are the only one that can mine your new coin. As mentioned above, you could lower the difficulty and just plug in your computer to mine as many coins as you like before releasing the software to the public. I don't know if that is how pre-mining is done in general, but you can surely do that.
hero member
Activity: 1190
Merit: 541
This is a very technical question and I believe it shouldn't be in altcoin discussion but in technical discussion section of the forum, you can also move it to project development mode, before then you can try downloading any good miner, I will advice you make use of CGMINER, you can search for it on google, download it then replace the IP in configuration with your seed node.

Make sure your wallet is open to avoid getting errors from the miner.
jr. member
Activity: 116
Merit: 8
If you are creating your own Altcoin then it would be easy to do a few minor changes in the code to premine the coins. You can fix the difficulty to lower limit and set the initial block reward to the premine number along with your coinbase transaction. Blocks which are mined later on will generate specified coins. By this way once you have mined the genesis block, it generates huge amount of coins as specified by you in the code and sends them to the address specified by you in the code.

If you have cloned the bitcoin core then you need to change the code further to spend your genesis block reward. There was a bug in the satoshi code which doesn't allow you to spend the reward which significantly affects your altcoin reward too. If you cloning a older bitcoin code, you can change the mining difficulty in mining.cpp or in the pow.cpp. I am not completely sure of this, but they will change the difficulty and help you premine those coins.

Thank you for the response.  I really do appreciate it.  Where I am at currently is have the daemon working on my new alt coin, have the wallet gui but now it is just generating the coins.  All this done on Ubuntu 16.04 vm.  I understand the generation of the hashmerkleroot and the genesisblock which I implemented in the code, generate the block ntime and nonce, setting the checkpoint with the block height set at 0 and DNS Seeds.  It is only how the coins are generated where I am still trying to understand.  From your response, this adds more knowledge in setting the difficulty in generating blocks.

To clarify, I have not cloned the bitcoin core, I cloned the compound coin source code and the source code is based on Peercoin.  I can explain further here or through DM; whichever you prefer.
legendary
Activity: 1584
Merit: 1280
Heisenberg Design Services
If you are creating your own Altcoin then it would be easy to do a few minor changes in the code to premine the coins. You can fix the difficulty to lower limit and set the initial block reward to the premine number along with your coinbase transaction. Blocks which are mined later on will generate specified coins. By this way once you have mined the genesis block, it generates huge amount of coins as specified by you in the code and sends them to the address specified by you in the code.

If you have cloned the bitcoin core then you need to change the code further to spend your genesis block reward. There was a bug in the satoshi code which doesn't allow you to spend the reward which significantly affects your altcoin reward too. If you cloning a older bitcoin code, you can change the mining difficulty in mining.cpp or in the pow.cpp. I am not completely sure of this, but they will change the difficulty and help you premine those coins.
jr. member
Activity: 116
Merit: 8
Hi All,

I have successfully cloned a POW/POS coin based on compound coin, generated the merkleroot and genesis block and a running gui wallet on Ubuntu 16.04.  The question now is how would I start to pre-mine my first coin?  I have researched and researched on the internet but most of examples show how to pre-mine POW wallets such as Litecoin.  By the way I was able to also clone Litecoin 0.8 through a tutorial and pre-mine by using the setgenerate command.  The problem with my cloned POW/POS coin is that there is no such thing as a setgenerate command.  Would anyone point me or help me on steps that I would have to take to pre-mine?  Would it be through running 2 daemons from 2 virtual machines (i.e virtualbox) and setting one as the server and the other the client?  I know that for the POW/POS coin one would first have to generate the coins then set the checkpoints and after let POS take over.

Any guidance or resources would be appreciated.

Has anyone successfully cloned an altcoin, generated the merkleroot and genesis block then generated coins on the first block of their new coin?  PM if need be.
jr. member
Activity: 116
Merit: 8
Hi All,

I have successfully cloned a POW/POS coin based on compound coin, generated the merkleroot and genesis block and a running gui wallet on Ubuntu 16.04.  The question now is how would I start to pre-mine my first coin?  I have researched and researched on the internet but most of examples show how to pre-mine POW wallets such as Litecoin.  By the way I was able to also clone Litecoin 0.8 through a tutorial and pre-mine by using the setgenerate command.  The problem with my cloned POW/POS coin is that there is no such thing as a setgenerate command.  Would anyone point me or help me on steps that I would have to take to pre-mine?  Would it be through running 2 daemons from 2 virtual machines (i.e virtualbox) and setting one as the server and the other the client?  I know that for the POW/POS coin one would first have to generate the coins then set the checkpoints and after let POS take over.

Any guidance or resources would be appreciated.
Jump to: