* To get paid sign up with my referral link for Digital Ocean:
https://www.digitalocean.com/?refcode=3a96071d7d5f Read more below and PM me to get paid.
Hello Everyone,
Some of you guys may know me from m previous guides or other things that I have written. Throughout my time with keeping my guides running, I have gotten multiple requests for a guide for how to create your own Digital Currency, so I have decided to finally sit down and write one. Here it is I hope you enjoy it!
To manage your coin you need some cloud servers. You can get cloud servers with any provider but for the first timer I highly recommend Digital Ocean due to how it works. This guide is designed for Digital Ocean. Plus if you sign up with my referral link and spend $10, I'll give you $4 in a currency of your choice or via. Paypal in order to help you cover your costs. Sign up here:
https://www.digitalocean.com/?refcode=3a96071d7d5f PM me to get paid. Or you can just let it run and PM me whenever you total $10 in billings getting paid then.
After you have your account you need 2 droplets to create your coin. I personally recommend 2 of the $40/month droplets as I find those are what work best. Name and location don't really matter. Once you create your droplet you will be emailed the necessary information to log in. Also make sure to use Debian 7.0 x64 as your image.
First things first. You'll need some source code. Since I doubt you can write it from scratch, you should be happy to know there are a bazillion different options in the scrypt-coin family for you to clone and alter. The most excellent research coin is good, SmallChange, by lightenup. His git diff output:
https://github.com/bfroemel/smallchange/commit/947a0fafd8d033f6f0960c4ff0748f76a3d58326 is nearly enough information to completely create your own alt-coin and as such should be lauded. His code is copy & pasted litecoin with some changes but he added some good comments throughout.
For the purposes of this tutorial and to preserve a "clean" copy of the SMC code, foocoin has been created:
https://github.com/foocoin/foocoin This guide will show you how to turn 'foo'coin in to 'bar'coin and you can take it from there. Enough has already been changed to make this coin compile-able if you follow this guide. If you'd prefer to start with the original SmallChange code, it is here:
https://github.com/bfroemel/smallchange.git or you could use the Litecoin, Franko, YAC, CHN, MIN, whatever source we'll change enough of it to make it work.
Now you need to find a coin name. You'll need to go to github.com/insertwhatevercodenameyouwanthere to see if the name is available If you get an error page where what your looking for isn't found then you know the name is available. Once you know your coin create a username email (normally yourcoinname@someservice.com) and whatever password you want - just make sure to make it secure!
Now you want to make one of those url's everyone can pull code from and use it. In the upper right hand corner next to your username click Create Repository. Fill in the blanks and you're done. Take note of the information.
*Note for the rest of this tutorial you will need either a Mac or Linux machine or Cygwin.*
Yes, you need one of them. For this tutorial, I will be using a MacBook with OSX 10.8.something and a Debian 7.0 64 (you can use 2 x 2 CPUs from DigitalOcean instead of Mac). I suppose you can use Cygwin, but I prefer the *nix's to Windows any day and you may as well learn one more thing too, right? Shoot, if you need a good LiveCD with the dependencies already built in that is set up to be run in a VMWare session, try CDEbian. Otherwise this guide uses Debian which means most mainstream clones should work (i.e.: Ubuntu, XUbuntu, Mint).
Setting up a PC or VM with Linux or OSX is outside the scope of this tutorial, but suffice to say I can vouch for VMWare and its ability to run multiple VMs simultaneously and its ability to virtualize OSX 10.6.x. You will need to install some dependencies on which ever OS you choose to be able to build the daemon and -Qt wallet.
Dependencies for OSX
The easiest way I've found to install dependencies on OSX is to use MacPorts or Homebrew. Personally, I like MacPorts better than Homebrew, but its simply because MacPorts installs in /opt (where I think it should go) and because MacPorts offers universal builds by default. If you prefer Homebrew, the formulas are the same, but I'd recommend building with the 32-bit flag. For the purpose of this tutorial, we're going to use MacPorts.
One needs to install the following dependencies:
boost (C++ libraries)
db48 (Berkeley DB 4.
qt4-mac (Open Source QT 4.8.4, includes qmake)
openssl (ssl dev libraries)
git (to move source back and forth to the repository)
miniupnpc (UPNP dev libraries, optional honestly I say skip this crap)
After installation of the basic MacPorts for your version of OSX, this can be accomplished with this command:
%sudo port install boost db48 qt4-mac openssl miniupnpc git
Once all of the dependencies are built and installed, the next step is to clone the source from git. In this example, I will be cloning foocoin, rename it, re-git initialize it, and push the initial copy out to Github to ensure git is working:
%git clone
https://github.com/foocoin/foocoin.git cloning in to foocoin
%mv foocoin barcoin
%cd barcoin
%rm -rf .git
%git init
initializing git repository in ~/barcoin
%git add -A *
%git commit -m "first commit"
%git remote add origin
https://github.com/barcoin/barcoin.git %git push -u origin master
username for git@github.com: barcoin
password for barcoin@github.com: **********
Now what did we just do? We cloned the existing source, deleted its link to git, reinitialized the folder for Github, added all the existing folders and files in to the repository, committed our changes (made them permanent and put them in the "Master" branch, renamed it in to our new *bigger *better *faster coin, set it back up to link to Github but to the *new* coin's account, and pushed a copy out to Github. Now if you go and look at your page it should look like so:
Oh, look at all that fresh source code just awaiting to be tweaked.
Dependencies for Linux
On Debian based Linux, dependencies and build requirements can be installed in a single command like so:
$sudo apt-get install sudo apt-get install build-essential libboost-all-dev libcurl4-openssl-dev libdb5.1-dev libdb5.1++-dev git qt-sdk libminiupnpc-dev
This will install all the needed packages as apt is very smart. Once that's complete, the same bits as above should be applied:
$git clone
https://github.com/foocoin/foocoin.git cloning in to foocoin
$mv foocoin barcoin
$cd barcoin
$rm -rf .git
$git init
initializing git repository in ~/barcoin
$git add -A *
$git commit -m "first commit"
$git remote add origin
https://github.com/barcoin/barcoin.git $git push -u origin master
username for git@github.com: barcoin
password for barcoin@github.com: **********
Dependencies for Windows
Ugh, I knew you'd ask. Windows is tricker than it should be when it comes to building with the GNU toolchain. First, you'll need mingw32 installed and dependencies built by hand for each of the listed items above. You'll also need to customize your -qt.pro file with the location of those dependencies. To simplify this, I've already compiled and assembled the needed dependencies in to a nice Github repository for you. If either downloaded and extracted as c:\deps or git cloned to C:\, this pacakge:
https://github.com/foocoin/deps.git will give you everything you need to build foo(bar)coin using the source you've already got. More about building the long way when we get to the Windows client compilation bit a little further along in the project.
Now you're ready to Cut and Paste!
Search and Replace
Ahh, now we've come to the creative part. The bit where you change the things you want to change to make your coin yours. As this is a *cloning* tutorial, I am not going to focus on the intricacies of programming (I'm not qualified). I'm simply going to show you where to make the changes you need to make to get a coin up and running. For this step, I really prefer TextWrangler on my Mac. It allows for multiple file searching and replacing which makes this portion of the process go quite quickly. If you're going to set up a VM to build -Qt wallets for Mac anyway, you should/could simply install the dependencies above and build within OSX completely. TextWrangler is free.
Names
TextWrangler will allow you to open an entire folder of files. Just open the program and choose File, the Open, highlight the "barcoin" folder and click Open:
Ahh, nice, all of the code in one easy to use interface. Be aware, that editing these files most certainly can be done via nano or Netbeans, or whatever other text editor, even Notepad I suppose. I just like this one, 'cuz of this next feature. Now we need to replace all instances of "FooCoin, foocoin, and FOOCOIN" in our source with "BarCoin, barcoin, and BARCOIN." Note the 3 different case settings most code has all three in it. To change this in TextWrangler, choose Search, then Multi File Search and select the "barcoin" directory:
Do this for all three case settings, or if you prefer e.e.cummings style, replace them all without the "Case Sensitive" box checked in one fail swoop. TextWrangler will show you the whole list of changed files and allow you to browse the changes once completed:
You will also want to replace all instances of "FOO" with "BAR." This is the 3 letter designation for your coin, like BTC or PPC. Finally, you will need to manually change the name of foocoin-qt.pro in the main source folder. Hey this is starting to come together, no?
Ports and Network Changes
Ok, now we need to give the new coin a unique port range to use. You'll need two ports, one for RPC connections (for miners to connect to) and one for P2P Connections. You can find a good list of reserved ports here:
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers Most any ports will work assuming they are 1: Over port 1024 and 2: not used by something else. I'd suggest something in the high numbers, good examples include 56679 and 56680 or 12365 and 12366.
For this example we're going to use 55883 for RPC and 55884 for P2P. In the foocoin sources, these ports are already set, so go ahead and modify them using your text editor of choice.
Change the RPC/P2P Port in the following files:
src/bitcoinrpc.cpp: (RPC PORT)
LINE 2893: ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 55883));
LINE 3169: if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "55883")))
src/init.cpp: (P2P PORT + Testnet Port)
LINE 235 " -port= " + _("Listen for connections on (default: 55884 or testnet: 45884)") + "\n" +
You can set the testnet port to any other random port, but remember what you set it to.
src/init.cpp: (RPC PORT)
LINE 271 " -rpcport= " + _("Listen for JSON-RPC connections on (default: 55883)") + "\n" +
src/protocol.h: (Testnet Port + P2P PORT)
LINE 22 return testnet ? 45883 : 55884;
You can also set an initial "seed node" or always on system that the new coin wallets coming online will check for additional addresses:
src/net.cpp:
LINE 1000 {"some website name", "somewebsite.org or ip x.x.x.x"},
Coins Per Block/Block Intervals/Max Number of Coins
These changes are also pretty simple. Change the following lines of code in the following files:
src/main.cpp: (Number of coins per block awarded)
LINE 831 int64 nSubsidy = 1 * COIN;
src/main.cpp: (How *should* blocks be found and how often difficulty retargets)
LINE 837 static const int64 nTargetSpacing = 120; // FooCoin: 2 minute blocks
LINE 836 static const int64 nTargetTimespan = 1 * 24 * 60 * 60; // FooCoin: 1 days
In this example, we want our coin to produce 1 coin blocks every 2 minutes and readjust difficulty once per day (1 day x 24 hours x 60 minutes x 60 seconds). You can adjust these, but know since this is a scrypt clone and we're not changing the starting difficulty this target rate will be skewed until the hash rate levels out on your new coin. This is tricky stuff and I don't quite understand all of it yet.
src/main.h: (Total number of Coins ever and Estimated # of Blocks per day)
LINE 43 static const int64 MAX_MONEY = 10000 * COIN; // maximum number of coins
LINE 550 return dPriority > COIN * 720 / 250; // 720 blocks found a day.
You'll need to do some math to figure out your blocks per day target based on how many coins you want to create over what timespan and how far apart your blocks are. I'm not doing all the work for you! This coin is set to give 1 coin blocks every 2 minutes, targeting 720 blocks per day through a maximum of 10,000 coins which means if mined hard, it will run out of coins in a week's time.
Address Starting Letter/Number
The first digit or letter of the new coin's address is determined by a base-58 code. You can see a list of all of the available options here:
https://en.bitcoin.it/wiki/Base58Check_encoding To change your coin's address edit this:
src/base58.h:
LINE 280 PUBKEY_ADDRESS = 38, //Set the address first bit here
Icons and Splash Images
You will find all of the supporting images and icons for the wallet in the src/qt/res folder. There are two folders with icons you should pay attention to:
and
Foo and bar coins both use the default Litecoin imagery. You should use an image editing program of your choice (I like Photoshop CS3, but GIMP is also nice) to edit the images. If you want rounded icons/images, use transparent .png files. Also, don't forget to generate an .ico (Windows/Linux) and an .icns (Mac) icon file for your program. A great website I like to use for this is here:
http://iconverticons.com/`
Merkel Hash
The Merkel hash is the root of your coin's network. Its the hash that all of the blocks will be measured against and the basis for mining a genesis block. My methodology is to get a coin working on the testnet first and then the main network by building and testing in a staged progression. The Merkel hash is not actually the first thing you need to change though.
Epoch Time
Since Midnight UTC on New Years Day, 1970, Unix (or Epoch or POSIX) time has been used to coordinate various system calls and functions of Unix systems (and many others by default). Since this kind of time is simple seconds and doesn't account for leap seconds, its an easy way to calculate unique time-based values for programming. To that effect, the first thing one must change when building a new coin is the base time for the birth of the coin or the genesis of the coin.
This is set in two places in the code, one for the test net:
src/main.cpp:
LINE 2023 block.nTime = 1300000000;
and one for the main net:
src/main.cpp: