Pages:
Author

Topic: How to make an altcoin. - page 3. (Read 11857 times)

member
Activity: 274
Merit: 10
November 24, 2017, 02:19:32 PM
#27
It looks like new alts will be introduced in few months after you post this topic.Im curious on how it works now i know how hard to create an altcoin.
full member
Activity: 150
Merit: 100
Official AltCreator Account
November 24, 2017, 12:36:10 PM
#26
Good Guide.

It helped me fix the errors i made in a Scrypt Coin.

If you want to make other algorithms, its basically the same thing. Just implement some additional stuff.
newbie
Activity: 4
Merit: 0
August 29, 2016, 12:31:45 PM
#25
I know this is a very old post but maybe you can help me out.  I made a forked version of litecoin-0.8.7.5. I am already mining it successfully. I then forked another version of litecoin (v.0.10.4.0) with all the same parameters but this new version won't connect may main node because version 0.8.7.5 doesn't indicate the folowing in red. I need to change the keys in red to ones that are compatible with litecoin-0.8.7.5
     
        base58Prefixes[PUBKEY_ADDRESS] = list_of(48);
        base58Prefixes[SCRIPT_ADDRESS] = list_of(5);   
        base58Prefixes[SECRET_KEY] =     list_of(176);
        base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);
        base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);


My question is where can I find these keys in litecoin-0.8.7.5, if they don't exist how can I generate them so that I can change the keys in v.0.10.4.0 accordingly. Or maybe I have the process backwards? Anyways, any info at all would be very useful and much appreciated.
full member
Activity: 227
Merit: 100
July 17, 2016, 03:04:59 PM
#24
can someone point me in the right direction for modifying the block time, block reward, total coins generated etc...
newbie
Activity: 6
Merit: 0
May 24, 2016, 05:51:10 PM
#23
Even this is old and I forking the 0.12.1 version which has some changes to the script you posted, This have been an excellent guide. Thank you.
But...I'm stuck right at the end.

I have been able to get the hash of the Genesis block, compile it and install it on three VMs on AWS and they connect between each other without issues. However, I'm not able to mine and generate a new block, neither in MainNet or TestNet. I have tried mining using differents miners (CPU minerd and CGMiner, even by setting the gen=1 parameter of the newCoin.conf of newcoind).

The problem is that miners are using the getblocktemplate RPC parameter and the client replies downloading blocks...
I only have one checkpoint added as you described in the chainparams.cpp file.

I'm able to mine without problems in regTest.

What am I doing wrong?

--Edit on this: after exactly one month!
I fix this by cloning the bitcoin client on version 0.10 instead of using 12.1. I think that in version 12.1 the internal bitcoin core miner is disabled so I was not able to mine by using the core client alone. In version 10, I had hashing power with the core client and able to mine some coins. After that, I was able to use the 0.12 core client without issues.

Thanks!
sr. member
Activity: 294
Merit: 250
please help gofund.me/bigs21024 Family in need
April 03, 2016, 07:10:09 PM
#22
easy pay me and ill do it lol but only if it is a good idea
full member
Activity: 120
Merit: 100
April 02, 2016, 05:23:49 AM
#21
Can any one post or suggest a guide on creating an altcoin with windows pc.
member
Activity: 98
Merit: 10
August 14, 2015, 12:01:40 PM
#20
very attractive, but none that I know, maybe I could just use  Grin
newbie
Activity: 26
Merit: 0
August 14, 2015, 11:34:39 AM
#19
Can this be compiled on Debian 8?
legendary
Activity: 2198
Merit: 1014
Franko is Freedom
May 29, 2015, 07:39:11 PM
#18
cool guide, there is an even easier way to mine a genesis block

https://github.com/lhartikk/GenesisH0
newbie
Activity: 2
Merit: 0
May 29, 2015, 07:34:09 AM
#17
I have neither ~/.newcoin no ~/.bitcoin directories available

I see the issue.
The code is creating (in chainparams.cpp) static instances of CMainParams CTestNetParams CRegTestParams (and CUnitTestParams for that matter) .. so the hashing code is getting executed before program main() is  invoked.

So I am not sure what you did to bypass that static instantiation to get the dialog box to come up.

I will put some std:cout calls to write to console and grab the initial hash values to replace in the code ...

Will that work as well ? Or will something not get created ( in ~/.newcoin) that needs to get created
legendary
Activity: 924
Merit: 1132
May 27, 2015, 09:54:54 PM
#16
Huh 

I don't know.  If the directory already existed, it wouldn't throw the dialog box.  So  first do a sanity check and type

cd ~/.newcoin

to see if the directory exists. 

If it does, your values will be in the last dozen lines of debug.log in that directory.

If it doesn't, then check ~/.bitcoin instead to see if you missed the file directory name when you were changing "bitcoins" to "newcoins."

newbie
Activity: 2
Merit: 0
May 27, 2015, 01:20:54 PM
#15

Mine the genesis block and insert the new values
Got all that? Now run newcoin-qt.

It will throw up a dialog box asking where to install. Let it have the default it wants, which will be a new subdirectory of your home directory named ~/.newcoin.

Then Nothing will happen.  For twenty minutes to an hour, usually.  Maybe more than an hour, depending on dumb luck and the speed of your computer.  If your computer’s slow, this may be a good time to go get a sandwich.

Here's what's actually happening.  It set the nonce, hashed the genesis block, noticed it didn’t match 0x01, and is now living in that tight little empty for loop, incrementing the hash, hashing the block, and checking to see whether the new hash is low enough to meet proof-of-work requirements.

After a while, it will die. Meaning, it found a nonce that gave the genesis block a hash low enough to pass proof-of-work, got out of the for loop, logged the new hash and nonce and the Merkle tree value, and then hit the assert that still insists on the hash value being Bitcoin’s genesis block hash value. So you want to see the new values. Type

tail ~/.newcoin/debug.log

and you’ll see the last few lines of logfile output.



When I run newcoin-qt, the dialog box does not come up ... instead the code goes immediately into code where the loop to generate the genesis hash
Code:
for(genesis.nNonce == 0; genesis.GetHash() > bnProofOfWorkLimit; genesis.nNonce++){ }
so no debug.log gets created and there is nothing to inspect afterwards.

What happened here?
legendary
Activity: 924
Merit: 1132
April 22, 2015, 10:52:35 PM
#14
Okay, this time I'm going to talk about how to claim the coinbase transaction from the genesis block.  Those who want to stick a premine into the genesis block should be paying attention here.


Get the private key for the coinbase
Earlier, we used openssl to get a key pair to use for the genesis coinbase.  We pasted the public key, in hex form, into the coinbase transaction of the genesis block.   Under normal circumstances this coinbase is not spendable. Because there is no wallet at the time the coinbase transaction is created, the private key does not get saved into a wallet.  But if we can import the private key into our wallet after the wallet is created, then the genesis coinbase can be spent.

So, go back to the key pair whose public key you used for the genesis coinbase.  The corresponding private key is the one you need to spend it.  But first you have to figure out what the heck it looks like in the base58 format that you can import into your wallet.

So you need to take the private key and do things to it, to get it into wallet-importable format.  

Here is the sequence of steps you need to do:  

First, take your private key:  For this example, let's say it's
Code:
0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
(which it certainly won't be, but I digress.)

Add the prefix byte for newcoin's secret keys.
Then, whatever byte you picked as the value for base58prefixes[SECRET_KEY] above, paste that byte in (in hex form!) as a prefix to the key.  We'll say our byte for base58prefixes was 0xAA.

So now you've got
Code:
AA0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF

Find SHA256D of the result

Now you take double SHA256 of that, which you can do from the command line again.
Code:
echo AA0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF | xxd -r -p > temp
puts the key in binary form into the file temp.
Code:
openssl dgst -sha256 temp
outputs the SHA256 hash of that key.  It will look like this:
Code:
SHA256(temp)= 855d46b953763179ae26937d7d5d9a7fbdf063f6e23fa5abc08e02b1ee202b0e
Now you copy the hex string and paste it into the following command:
Code:
echo 855d46b953763179ae26937d7d5d9a7fbdf063f6e23fa5abc08e02b1ee202b0e | xxd -r -p > temp2
The effect of that is to put the hash of the key, in binary form into the file temp2.  So now you can get SHA256 of the hash like so:
Code:
openssl dgst -sha256 temp2
and openssl will spit out the hash of the hash.  

The effect is to do 2 iterations of SHA256 on the private key:  Without piping through xxd both times, we'd be doing SHA256 on a string of bytes which happens to be the ASCII representation of the hexadecimal string instead.  Anyway, the output from that is the  SHA256D hash of the prefix byte plus private key.  For our example, it happens to be
Code:
SHA256(temp2)=02709d7a22eebf159eb9e67669afb4c565a6fa90d9ac2f6069beccce226b04ab

Extract the checksum bytes from the SHA256D hash
The first four bytes of that - which are 02, 70, 9d, 7a, are the checksum for the private key - this is a four-byte code that is appended to keys to make it extremely unlikely (about one chance in four billion) that a mistyped key will actually be a valid key.  This is intended to make it unlikely that people spend coins to wrong addresses.  Of course they do that anyway, but thanks to this checksum it's not because they mistype the addresses.


Append the Checksum bytes to the prefix-extended key
Anyway, you take the key, with the prefix byte, and put the checksum bits at the end of it, so you get
Code:
AA0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF02709D7A.

Now, this is a number in hexadecimal, which you have to convert into base58check form.  https://en.bitcoin.it/wiki/Base58Check_encoding  on the bitcoin wiki explains how base58check is encoded, but doesn't point at any handy utility to actually do it that doesn't depend on bitcoin's secret-key prefix.  So I'm going to code one.

A simple little lisp dialect called Scheme, believe it or not, is my favorite scripting language.  I have mit-scheme on my machine, and Scheme has standard bignums and understands numeric notation in hexadecimal.  If you're happier doing this sort of thing in Haskell or Eiffel or Python or whatever, use that instead.  But I'll actually write the six-line program for you if you want to use Scheme.  If you don't have it on your system, you can type

Code:
sudo apt-get install mit-scheme
to get it. Then at the command line type
Code:
mit-scheme

to start it, and paste this function definition into it:

Code:
(define (base58check input)
   (define (base58digit k) (string-ref "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" k))
   (define (extractdigits n digits)
       (if (> 58 n)
         (list->string (cons (base58digit n) digits))
  (extractdigits (quotient n 58) (cons (base58digit (modulo n 58)) digits))))
   (extractdigits input '()))

Now you just have to give your key to that function as a hexadecimal number:

Code:
(base58check #xAA0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF02709D7A)

and mit-scheme will politely cough out the base58check form of it;  In our example, this is the string

Code:
"6hU445Fi7j2WSwc2uLsbcQMJ1r2xbENWxGdfxTApKaRRaQ2Ppk1"

And that is the form of the key that you need to import into your wallet, to enable you to spend the coinbase transaction from the genesis block.

Cool, huh?  Now type
Code:
(exit)
and then 'y' at the yes/no prompt, to quit scheme.

Adding a Premine

Now we're going to come to one of the most abused features of cryptocurrency; I'm going to explain how to add a premine.  

The next thing, if you want to treat the genesis coinbase as your premine, is the question, how to change the amount?  There are three things you have to change.  The obvious thing is in chainparams.cpp,  in the line above the one where you pasted in the coinbase tx public key.  It's at the line where the code says

Code:
txNew.vout[0].nValue = 50 * COIN;

So, we'll say you want 5000 coins instead of 50 for your premine.  That's an easy enough change here; you just change the number here so it says
Code:
 txNew.vout[0].nValue = 5000 * COIN;
instead.  

Change GetBlockValue to Allow your Premine
But this is only the obvious thing.  There are two other things you have to change for this to work.  The next one is the function GetBlockValue in main.cpp.  If you don't change this, your block chain will not be valid when your client tries to check it. This function says what the coinbases are supposed to be worth, and if the client checking the block chain finds a coinbase transaction that doesn't match what this function says it ought to be, then it will reject the genesis block.  The function looks like

Code:
CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
    CAmount nSubsidy = 50 * COIN;
    int halvings = nHeight / Params().SubsidyHalvingInterval();

    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return nFees;

    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;

    return nSubsidy + nFees;
}

and you want to make the subsidy for the block at height zero (ie, the genesis block) worth 5000 coins instead of 50.  And while we're here we might as well correct the comment's assumption of ten-minute blocks.  So your revised function can look like this:

Code:
CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
    CAmount nSubsidy = (nHeight == 0 ? 5000 : 50) * COIN;
    int halvings = nHeight / Params().SubsidyHalvingInterval();

    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return nFees;

    // Subsidy is cut in half every 350,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;

    return nSubsidy + nFees;
}

Then go back to chainparams.cpp  and set the subsidy halving interval to 350000 instead of 210000 to maintain the 4-year halving interval (assuming you want a 4-year halving interval).  Another effect of this change is that it will also change your ultimate number of coins to be issued to be ~35M instead of ~21M.  

Regenerate the Nonces

Okay, that was the second of three things.  Now for the third.  You should already know what this is.  When we changed the genesis coinbase,  We changed the hash of the transaction.  And when we changed the hash of the transaction, we changed the merkle root in the genesis block.  And that invalidated our nonce.  So you need to mine your genesis blocks again.  

I covered this already when I explained how to mine genesis blocks.  You go back to chainparams.cpp, change the 'false's to 'true's, erase the ~/.newcoin directory, compile, and start it up.  It'll take a while.  Then you look at the debug.log in the (re-created) ~/.newcoin directory to get the new values.  Paste them in for the main params, Rinse, repeat, paste in the testnet params.  Rinse, repeat, paste in the regtest params.  Then change the 'true's to 'false's, and compile again.

So now newcoin has a genesis block coinbase with a premine of 5000 coins, and you have a key you can import into your wallet later which will allow you to actually spend the 5000 coins.

Changing the number of coins that can be issued

With your premine and different halving interval you've changed the number of coins that can be issued.  But you need to change other parts of the code for this to be fully supported.  The first and most obvious is in amount.h, where it says
Code:
/** No amount larger than this (in satoshi) is valid  */
static const CAmount MAX_MONEY = 21000000 * COIN;
And, obviously, you change the 21000000 to 35004950.  (remember, you added 4950 coins to the total when you changed the output of the genesis coinbase).


The second is in rpcserver.cpp, in the function AmountFromValue. It looks like this:  
Code:
CAmount AmountFromValue(const Value& value)
{
    double dAmount = value.get_real();
    if (dAmount <= 0.0 || dAmount > 21000000.0)
        throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
    CAmount nAmount = roundint64(dAmount * COIN);
    if (!MoneyRange(nAmount))
        throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
    return nAmount;
}
And once again, you need to change that 21000000 to 35004950.  And now you have code for a client that is correct for your new block spacing and coin distribution.  

legendary
Activity: 924
Merit: 1132
April 21, 2015, 09:50:01 PM
#13
Bump.  I've updated the article above on Difficulty Adjustment, and also posted it to a blog so now there's a link to the online article.
member
Activity: 171
Merit: 12
April 21, 2015, 03:01:30 PM
#12
This is a fascinating thread. Thanks for the info.
legendary
Activity: 924
Merit: 1132
April 20, 2015, 07:55:24 PM
#11
Bump.  I edited the post adding code for the MIDAS difficulty adjustment system. 
legendary
Activity: 924
Merit: 1132
April 20, 2015, 02:15:09 PM
#10

Sure.  I haven't made the new edits on my blog post yet, but please include a link back to it.


Okay, I've got the new edits in the blog post now.  So linking to it will get you a better version. 
legendary
Activity: 924
Merit: 1132
April 20, 2015, 01:27:43 AM
#9

Two different guides. I'm pretty sure the name change is one of the first parts to the clone. Both are different and both cater for different needs. If you get stuck on something when you go through windows give me a yell.

Thank you for that.  And I'm likely to take you up on it when I think I've got stuff ready.  Recent versions of Windows are completely a mystery to me, and I wouldn't know where to start. 

Question? Can I post you guide there?

Sure.  I haven't made the new edits on my blog post yet, but please include a link back to it.

Oh and the windows command line thing. I like to visually edit my code personally, this gives me a better understanding of what happening also around the code I am editing. Each to their own though.

Sure, I understand that.  When I'm getting ready to support a codebase, I spend hours a day just READING the code to try to understand all the parts and how they work together.  So I completely understand the need to see it and get familiar with it and see how everything interacts.  The name change though, is total and unambiguous, so it can really be done in one step and doing it otherwise I'd be afraid of missing stuff or making mistakes. 

I know Windows works really well for a lot of people, but all I really remember about it is being frustrated whenever I tried to do anything complicated from the command line.  It has environment variables, some filename globbing and you can use pipes to send output to files or devices or the next command, so the command line isn't overtly broken.  But recursive utilities, stream editors, patterned renaming, anything like the find command...  I never discovered any way to do those things. I don't know if that's because I just am ignorant about tools and utilities available on Windows, or if those tools and utilities really don't exist.  Anyway, I don't mean to insult it - I just don't know how people do the tasks that make me reach for those utilities. 

I guess I'm writing this guide aimed at Unix/Linux users because I don't even know HOW to do most of this stuff on Windows.

legendary
Activity: 1008
Merit: 1022
April 20, 2015, 12:52:38 AM
#8
Pages:
Jump to: