Learning The Basics of Altcoin Daemons and CLI

Altcoin Daemons

Once you have compiled an Altcoin based on Bitcoin you will end up with a bunch of binaries in your /urs/local/bin/ folder. Usually you will find that there is one named something like "ALTCOINNAME-QT", that binary is the one that will launch the GUI (graphical user interface) wallet. That is the classic Bitcoin experience with all the bells and whistles that the developer decided to put in there. But what do we do if there is a coin that doesn't have a qt wallet, or has one, but it is for one reason or another broken? Well, we will need to use the daemon and command line interface (CLI).

This may seem trivial, as most newer Altcoins are popping up with pools almost as soon as they launch. However, you may not want to use an online wallet. In that case you will need to use the daemon and CLI with RPC (remote procedure call). With it you can create a wallet, get an address, and do other things.

Setting Up The Daemon

In techno-speak, a daemon is simply something that runs perpetually in the background of a computer. Daemons normally run silently in the background when you launch an Altcoin GUI wallet. In this instance we won't be using a GUI wallet, so we will need to launch just the daemon.

Starting the daemon is usually pretty straightforward. All you need to do is open up a terminal window and run altcoinnameD. The daemon binary is usually the name of the coin with a "d" added onto the end. When you run the daemon it spits out all of the tasks that it normally does, as its primary goal is to connect to other peers on the Altcoins network and then support all the functions of the wallet, such as addresses and transactions.

If you happen to run an Altcoin daemon and it doesn't start printing anything out in the terminal window, hit the close command (Command + C) and then rerun the daemon with the --print-to-console modifier like so:

$ altcoind --print-to-console

However, launching the daemon right off the bat isn't going to yield the configuration that you may want. For general purposes, if you plan on solo mining a coin, you will have to configure it to work the way you want. More importantly, you will need to set up a username and password for the RPC so that you can use a tool like CGminer or CPUminer.

What Goes Into a Configuration File?

Creating a configuration file is pretty simple, go ahead and launch Sublime Text and create a new blank file. We are going to start with five basic lines for our configuration file: server, rpcuser, rpcpassword, rpcport, and rpcconnect.

server

The server line tells the daemon if it should create a local server for you to connect to via CLI or a miner with RPC. A value of 0 tells the daemon that it should not run a server, a value of 1 tells the daemon that it should.

rpcuser

The rpcuser line tells the daemon what username it should expect when its connect to from CLI or RPC. If you are solo mining usually you don't need anything complicated in this line.

rpcpassword

The rpcpassword line tells the daemon what password it should look for when it receives a connection request.

rpcport

The rpcport line is what port the server should be looking for incoming connections on. Usually you set this to 9332. However, some systems might lock the port to that Altcoin permanently. So you may need to change ports if you plan on mining multiple Altcoins.

rpcconnect

The rpcconnect line is what IP address the local server should be set to operate on. Again there is a standard rule here that it should be run on 127.0.0.1, as that IP address is typically seen by operating systems as the computer itself, also known as localhost.

Built The Altcoin .Conf File

With all of those lines, you are telling your Altcoin daemon that it should run a server, where it should run it, and the credentials that it should look for from the user. There are other, more advanced options, but those may or may not bee enabled by the Altcoin's developer, so we really don't need to worry about them at the moment.

A standard configuration template is below. Open up Sublime Text and copy the contents to a new file.

server=1

rpcuser=*YOURUSERNAME*

rpcpassword=*YOURPASSWORD*

rpcport=9332

rpcconnect=127.0.0.1

Once you have the template made, you should save it to the default data directory. The default data directory for the Altcoin, usually this exists in the ~ directory with a name like .lawrium. That is the folder we want to save the .conf file to. When saving you should name the file "ALTCOINNAME.conf" and replace ALTCOINNAME with the name of the Altcoin. For example a configuration file for Lawrium, would be named lawrium.conf. Don't capitalize the file name, as by default it wont be looking for it with a capitalized name. Once saved, open up a terminal window and move the active directory to the location where you saved the file.

Launch The Daemon

Now that we have our configuration file in place for the Altcoin daemon, we are ready to go ahead and launch it. Open a terminal and run the command to launch the daemon for your Altcoin. If you have forgotten the name of it binary, simply use cd /usr/local/bin to skip over to the folder and see whats in there. A quick note here, when you run things like daemons from terminal, you need to know that closing them can be done in two ways: 1. you can close the terminal tab or window to end the task, or 2. you can press the correct key combination. In Ubuntu, this key combination is control-c, stylized as ^C in the terminal window (although you won't need to hold down the shift key to make it happen).

It's Command Line Time

Now that the daemon is running, we will need to either open a new terminal window or tab. The current window or tab is busy running the daemon, and its where we will need to go to stop it later. Before we launch into running commands on the command line interface, we need to know exactly what to expect. Presumably we have all played around in the console of a GUI cryptocurrency wallet doing things like typing "getwork" or "setgenerate 1". CLI for an Altcoin daemon is literally just a backdoor to this console that we can see in the GUI wallet.

First thing is first, lets get connected and see what can do. To see the formatting specifics (which are worth checking as the Altcoin author may have done some funky customization) go ahead and run the CLI binary without anything after it. We will stick with using Lawrium as an example.

$ lawrium-cli

You may notice that I didn't include the ./ there. Since we are launching a full binary, and not a script, we don't have to include the ./ before the name of the binary. If we want to we can, but its not necessary. Anyway, after entering just the name of the binary, you should get a printout of what all the CLI binary can receive as modifiers.


As you can see the help dialog that is generated by lawrium-cli is not only telling you what information it can pass along to the server, but also what format you need to put the information into. Now, you may notice that there is a line in there for configuration file, for most CLI uses we will not need it. Instead, we can simply type "help" (or any other Altcoin console command) after the binary name and it should pass along the command to the daemons console.

If you are having issues with it not connecting to the terminal, try adding the rpcconnect modifier after the binary name like the example below to see if that forces it to connect.

$ lawrium-cli -rpcconnect=127.0.0.1 help

This time you will get a different printout, and you will notice, its the console commands for the console that you would find in the GUI wallet! That means that you are now talking to the daemon for the Altcoin!

From here we can do some serious things, like create new addresses, wallets, or whatever else is enabled via console commands. My most common activities in CLI are to create a new receiving address so that I can set up mining software.