Pages:
Author

Topic: How to make an altcoin. (Read 11858 times)

copper member
Activity: 136
Merit: 3
October 02, 2022, 10:11:34 PM
#67
Awesome! So glad to of found this all the good stuff on this forums is buried...
newbie
Activity: 4
Merit: 0
December 29, 2021, 03:21:02 PM
#66
Hello,

When forking a coin, is there any specific hardware required?
newbie
Activity: 3
Merit: 0
July 31, 2021, 12:12:14 PM
#65
Any simpler coin to fork? I heard Bitcoin used to have like 3000 lines of code, while now it has 100k+
A simpler coin with less code should be easier to fork and work on top of.
newbie
Activity: 12
Merit: 0
May 23, 2021, 10:38:46 PM
#64
Cryddit, can you please update MIDAS to make it work with the latest Litecoin code? Thanks.
newbie
Activity: 3
Merit: 0
December 22, 2019, 02:11:40 PM
#63


AlgoniZEXYZ - Live BTC BTCUSD Trading Signals | ICO Coming Soon
https://www.youtube.com/watch?v=yGuRO9zJLdI

In Partnership With Trading View, Quantconnect and much more partnerships to be completed.
Programming Languages used, Python (Machine Learning + AI), AFL, MQL4 etc.

Worldwide Developers are Invited



member
Activity: 294
Merit: 13
AKA merlin.
October 22, 2019, 03:58:52 PM
#62
I didn't give away the last bit of how to get the premine done.  I gave the information to get about 90% of the way there.  I told you how to figure out what the key you needed to import that transaction would be.  But I guess what the hell.  We'll go to 99%.  

There's a database of uncommitted transactions.  Processing a block, the software takes transactions from this database to add txOuts to your wallet - whenever it finds one of the uncommitted transactions in the block.  

Normally this is fine. When it's forming a block itself, it adds the coinbase tx to the database before it processes the block.  When it's checking existing blocks, it adds the transactions it sees in the block to the database when it receives the block.

Your problem is that the genesis block is causa sui. The software isn't forming the genesis block itself, and it didn't receive it.  So the initial coinbase transaction doesn't get into the database of pending transactions in either of the two "usual" ways.

Your software sees a valid block, where every transaction checks as a valid transaction, etc.  It decides to accept the block. So when it accepts the block as part of the block chain, it takes everything in its database that matches any of those transactions (ie, nothing in the case of the Genesis block) and checks all of that stuff to see if there's a txOut in it that can be added to your wallet.  If it finds the txOut, it adds it to your wallet.  It didn't add the genesis coinbase.  No problem, I told you how to import it yourself after the fact.

So you imported the key, and it imports just fine, because it looks back through the blocks, and sure enough, there exists such a coinbase transaction.  But then you try to actually spend it, and when it's checking the transaction it repeats the whole "did this txOut successfully get imported from the database?" check, and observes that no, that's an empty damn database when the genesis block is processed and no such amount exists.

This was supposed to be sort of an "exam question" - somebody who is capable of making and maintaining an altcoin is expected to be able to figure it out.

That would involve going to see where txOuts get added to the wallet, tracing back to see why the genesis coinbase wasn't making it, figuring out that the txOuts get added to the wallet when they are looked up in the database, discovering that the coinbase txOut isn't in the database when the block gets processed,  looking to see when and how transactions get into the database, realizing that neither of those things were happening in the case of your genesis block, and then correcting the problem.  A moderately involved case of debugging a code problem.


The modifications I tried does not work.

Giving away the 1 % of the answer that remains would be great !
full member
Activity: 504
Merit: 100
Powered by Artificial Intelligence & Human Experts
December 08, 2018, 03:08:01 PM
#61
It is really easy to make an altcoin right now, the best and fastest way to make one would be to make one of the tokens that are being created on the ethereum network, it does not take a long time to create and also does not take a lot of money to create them. Just google it, there are a lot of tutorials out there to do them
full member
Activity: 615
Merit: 154
CEO of Metaisland.gg and W.O.K Corp
member
Activity: 294
Merit: 13
AKA merlin.
member
Activity: 294
Merit: 13
AKA merlin.
October 26, 2018, 08:16:16 PM
#58
It still didn't work.......   segmentation fault........

So after a bit of research, it's possible that there was a fourth and fifth code change needed...

---------------------


1- Allow genesis block tx connection ( disable skipping the genesis block )....
----------------------------------------------------------------------------------------------------

// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
        if (!fJustCheck)
            view.SetBestBlock(pindex->GetBlockHash());
        // return true; <- comment this line out
}



2- Skip assertion of previous block for genesis block....
---------------------------------------------------------------------

From ----------------->

assert(pindex->pprev);

TO --------------------->

if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
    assert(pindex->pprev);
}


3   4    and  5    - Skip writing undo data for genesis block....
-------------------------------------------------------------------------------

from -------------->


if (block.vtx[0]->GetValueOut() > blockReward)
      return state.DoS(100,
                       error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                             block.vtx[0]->GetValueOut(), blockReward),
                             REJECT_INVALID, "bad-cb-amount");



to ----------->

if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
   if (block.vtx[0]->GetValueOut() > blockReward)
      return state.DoS(100,
                       error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                             block.vtx[0]->GetValueOut(), blockReward),
                             REJECT_INVALID, "bad-cb-amount");
}



AND

FROM---------->

if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
        return false;


TO-------------->

if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
{

    if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
        return false;
}



AND

FROM---------------->

static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams)
{
    // Write undo information to disk
    if (pindex->GetUndoPos().IsNull()) {
        CDiskBlockPos _pos;
        if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
            return error("ConnectBlock(): FindUndoPos failed");
        if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
            return AbortNode(state, "Failed to write undo data");

        // update nUndoPos in block index
        pindex->nUndoPos = _pos.nPos;
        pindex->nStatus |= BLOCK_HAVE_UNDO;
        setDirtyBlockIndex.insert(pindex);
    }

    return true;
}


TO-------------------------->


static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams)
{
    if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
   {




       // Write undo information to disk
       if (pindex->GetUndoPos().IsNull()) {
      CDiskBlockPos _pos;
      if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
          return error("ConnectBlock(): FindUndoPos failed");
      if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
          return AbortNode(state, "Failed to write undo data");

      // update nUndoPos in block index
      pindex->nUndoPos = _pos.nPos;
      pindex->nStatus |= BLOCK_HAVE_UNDO;
      setDirtyBlockIndex.insert(pindex);
       }

       return true;
   }
}

---------------------------------------------------------------------------------------------------

This is for Bitcoin's  latest 0.17 version....


I will test this right now !
member
Activity: 336
Merit: 10
October 26, 2018, 09:05:09 AM
#57
It is very difficult to create a worthwhile altcoin, which will be popular. The main goal that should be pursued by those who create altcoins is not enrichment, but improvement of the product that you have at the expense of blockchain technology.
member
Activity: 294
Merit: 13
AKA merlin.
October 26, 2018, 08:49:36 AM
#56
In order to make the coinbase spendable, the following changes have to be made to validation.cpp (v0.16.2). Note: this would be considered a hard fork.

Step 1 - Disable skipping the genesis block (which is intended to keep the bug as part of consensus), Line 1818:

// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
        if (!fJustCheck)
            view.SetBestBlock(pindex->GetBlockHash());
        // return true; <- comment this line out
}

Step 2 - Skip assertion of previous block for genesis block, Line 1874:

if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
    assert(pindex->pprev);
}

Step 3 - Skip writing undo data for genesis block, Line 1989:

if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
{
    if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
        return false;
}

Now adapt it to 0.10.0 in main.cpp .....

And the coinbase tx is spendable !!!
member
Activity: 294
Merit: 13
AKA merlin.
October 26, 2018, 06:22:52 AM
#55
I think I got it.

// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == Params().HashGenesisBlock()) {
        view.SetBestBlock(pindex->GetBlockHash());
        return true;
}


TO   ------------------>

// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == Params().HashGenesisBlock()) {
        view.SetBestBlock(0);
        return true;
}

Correct me if i'm wrong.......   doing tests right now t osee if it works !

 dosen't work.......  here is the error :

as soon as I try to mine....

CreateNewBlock(): total size 1000
imperiumd: main.cpp:1647: bool ConnectBlock(const CBlock&, CValidationState&, CBlockIndex*, CCoinsViewCache&, bool): Assertion `hashPrevBlock == view.GetBestBlock()' failed.
Aborted (core dumped)

copper member
Activity: 479
Merit: 11
October 26, 2018, 12:01:36 AM
#54
Good information honestly I still don't have a coin that was made like this, all of the tokens I've traded and stored are all Ethereum and Stellar based it's much different now creating a coin is much simpler and cheap now in fact so many are offering this service.
member
Activity: 294
Merit: 13
AKA merlin.
October 25, 2018, 11:46:10 PM
#53
in main.cpp

line 1649 or so, depending on bitcoin's version :




    // Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == Params().HashGenesisBlock()) {
        view.SetBestBlock(pindex->GetBlockHash());
        return true;
    }
legendary
Activity: 924
Merit: 1132
October 25, 2018, 01:42:33 AM
#52
I've been looking at it again recently because I'm thinking of undertaking a new block chain project of my own. I may even update it to the current bitcoin sources.

But what I have in mind goes in a sharply different direction from Bitcoin, so simpler (earlier) versions could be a better starting point too.  Still deciding what to base it on.
legendary
Activity: 924
Merit: 1132
October 25, 2018, 01:05:47 AM
#51
I didn't give away the last bit of how to get the premine done.  I gave the information to get about 90% of the way there.  I told you how to figure out what the key you needed to import that transaction would be.  But I guess what the hell.  We'll go to 99%.  

There's a database of uncommitted transactions.  Processing a block, the software takes transactions from this database to add txOuts to your wallet - whenever it finds one of the uncommitted transactions in the block.  

Normally this is fine. When it's forming a block itself, it adds the coinbase tx to the database before it processes the block.  When it's checking existing blocks, it adds the transactions it sees in the block to the database when it receives the block.

Your problem is that the genesis block is causa sui. The software isn't forming the genesis block itself, and it didn't receive it.  So the initial coinbase transaction doesn't get into the database of pending transactions in either of the two "usual" ways.

Your software sees a valid block, where every transaction checks as a valid transaction, etc.  It decides to accept the block. So when it accepts the block as part of the block chain, it takes everything in its database that matches any of those transactions (ie, nothing in the case of the Genesis block) and checks all of that stuff to see if there's a txOut in it that can be added to your wallet.  If it finds the txOut, it adds it to your wallet.  It didn't add the genesis coinbase.  No problem, I told you how to import it yourself after the fact.

So you imported the key, and it imports just fine, because it looks back through the blocks, and sure enough, there exists such a coinbase transaction.  But then you try to actually spend it, and when it's checking the transaction it repeats the whole "did this txOut successfully get imported from the database?" check, and observes that no, that's an empty damn database when the genesis block is processed and no such amount exists.

This was supposed to be sort of an "exam question" - somebody who is capable of making and maintaining an altcoin is expected to be able to figure it out.

That would involve going to see where txOuts get added to the wallet, tracing back to see why the genesis coinbase wasn't making it, figuring out that the txOuts get added to the wallet when they are looked up in the database, discovering that the coinbase txOut isn't in the database when the block gets processed,  looking to see when and how transactions get into the database, realizing that neither of those things were happening in the case of your genesis block, and then correcting the problem.  A moderately involved case of debugging a code problem.
sr. member
Activity: 882
Merit: 250
Founder Nur1Labs
October 24, 2018, 11:50:22 AM
#50
Ok... so I got a max total supply of 210 000 000 coins... wanted to add a premine of 37 800 000 coins ( 18 % )

Its added when I import the private key...

But as soon as I try to spend it, any transaction is not added to the memory pool, and the whole premine amount just disappear from my wallet...

What am I doing wrong ?

I'm using Bitcoin's 0.17 version, maybe it is not compatible for the premine method ?

Maybe the method is good for 0.10 but 0.17, with the new code, is not appropriate for this method ??






i think newer one you need seek on commit what they change too sometimes they already hard code it like dash already lock.....you need base or rebase thing~
member
Activity: 294
Merit: 13
AKA merlin.
October 24, 2018, 03:34:12 AM
#49
Ok... so I got a max total supply of 210 000 000 coins... wanted to add a premine of 37 800 000 coins ( 18 % )

Its added when I import the private key...

But as soon as I try to spend it, any transaction is not added to the memory pool, and the whole premine amount just disappear from my wallet...

What am I doing wrong ?

I'm using Bitcoin's 0.17 version, maybe it is not compatible for the premine method ?

Maybe the method is good for 0.10 but 0.17, with the new code, is not appropriate for this method ??




sr. member
Activity: 882
Merit: 250
Founder Nur1Labs
October 04, 2018, 09:31:55 PM
#48
on some point just used rebase thing on fork mode and you got that same implemented. on my case i used rebase dash so easy to found how to made. but problem you need have team to build this not alone. + need goal what for made~
Pages:
Jump to: