Since there are so many garbage coins out there, I decide to create
this course to teach you how to create a new alt coin. It's so simple,
that I can usually do within 2 hours.
You need to have some basic knowledge of C++ programming. No need
to be an expert, but you need to understand the basic compiling errors
and how to fix them.
Follow the following steps to create a new alt coin:
Preparation Step:
Download the Litecoin full source code, you can find it in github, just
do a google, you'll find it.
If you use windows, follow the steps in this thread:
https://bitcointalk.org/index.php?topic=149479.0
set up environment and libs, and compile the Litecoin. If you are successful
in compiling it (and run it), then your environment is good.
Design your coin:
Now that you have env set up, before doing coding, you need to do some design of
your coin, this is simple math calculations, but you need them for parameters
in the coding.
Basically you need to determine what you want:
There are some other things you may want to adjust, such as initial diffculty etc. But usually I don't want to bother with these.
Now with these parameters defined, one important thing is that you want to calculate how many blocks/coins
generated in a month, a year etc, and total coins ever will be generated. This gives you a good idea how overall
your coin will work, and you may want to re-adjust some parameters above.
Now the code change part.
Before you begin, copy the whole directory of Litecoin to Abccoin. Then modify the code in Abccoin.
Follow the below steps for code changes:
Note: smallchange 1st commit does not include many of the changes I will outline below, but it is a
good reference for what need to be changed.
In Abccoin/src dir, do a search on "LTC", and change them to "ABC".
Change the ports: use the ones you defined in coin design, and change in the following files:
for the last item, refer to Luckycoin code, you will see how this is done.
For random coin values in block, refer to GetBlockValue() function in JKC and Luckycoin code.
According to your coin design, adjust the value in main.h:
Change transaction confirmation count (if you want say 3 confirmation transaction etc) in transactionrecord.h
also change COINBASE_MATURITY which affects the maturity time for mined blocks, in main.h/cpp.
Create genesis block. Some people get stuck there, it's really easy:
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()
Quote
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).
Also you need to change the alert/checkpoint key, this depends on the coin type and version, you can find it in main.cpp, main.h, alert.cpp and checkpoint.cpp.
change corresponding "starts with " in sendcoinsentry.cpp
change example in signverifymessagedialog.cpp
open checkpoints.cpp
there are 3 functions, comment out the normal return, and make them return either true, 0, or null, like this:
Quote
bool CheckBlock(int nHeight, const uint256& hash)
{
if (fTestNet) return true; // Testnet has no checkpoints
MapCheckpoints::const_iterator i = mapCheckpoints.find(nHeight);
if (i == mapCheckpoints.end()) return true;
// return hash == i->second;
return true;
}
int GetTotalBlocksEstimate()
{
if (fTestNet) return 0;
// return mapCheckpoints.rbegin()->first;
return 0;
}
CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex)
{
if (fTestNet) return NULL;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
{
const uint256& hash = i.second;
std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
// return t->second;
return NULL;
}
return NULL;
}
Now this is disabled. Once everything works, you can premine 50 blocks, and extract some hashes and put them in the checkpoints, and re-enable these functions.
That's about it. You can do compilation all the way along, no need to do in the end, you may get a lot compilation errors.
Oh, icons:
Find a nice image for your coin, then make 256x256 icons/images. You have 5 images to replace in src/qt/res/icons, and 1 to replace (splash) in src/qt/res/images.
Oh also edit those files in qt/forms. These are files for help etc, better make them look nice, display your coin names than litecoin ones.
Now for compilations:
qt: modify the .pro file under abccoin, and follow the make process in
https://bitcointalk.org/index.php?topic=149479.0
daemon: update one of the makefile for your system, and in my case I use mingw32 shell to make.
That's it, voila, you have your own alt coins!!