Mining cryptocurrency on an Android phone

It’s easier than you think to install a cryptocurrency miner on an Android phone – and you don’t even need to hack the system software

Note: the mining pool referred to below seems to be non-operational. Please use https://poolium.win/ instead. I will update the tutorial later.

If you have an Android phone or tablet that has passed its use-by date, or if you just want to set up a low energy miner, it’s relatively easy to do. The basic tutorial is found here, on the iMineBlocks channel:

(26:06)

There are two things to note with that tutorial. Firstly, it was specifically devoted to Fireworm, a fork of cpuminer. Fireworm is a Verium miner exclusively. The good thing about Verium is that it is a CPU coin, which means that GPUs will not give you any advantages over a CPU that uses the same Wattage. Secondly, the tutorial was based on Linux Deploy, which requires root privileges. That sort of stuff is unnecessarily complicated, and you will not always succeed, depending on what rooting method you use, and what device you are using.

This tutorial will eventually discuss how to set up an account with a mining pool. A mining pool is a collective of individual miners who share the burden of mining a given coin. Mining solo is possible but you will have more consistent rewards if you’re a member of a pool. But we want to get the miner successfully installed first.

This tutorial is based on the video above, and you will be installing Fireworm. But there will be one change: we are going to base our installation of Fireworm on UserLAnd, a Linux installation that does not require root privileges. Rooting an Android device is a pain, as you don’t know if the process is going to work or not. While Android is based on Linux, it is not Linux proper, and so you do need to install a distribution of Linux to use Linux applications.

Firstly, let’s have a look at the commands as Lee, the channel owner, has written them:

apt-get update
apt-get upgrade
apt install git gcc g++ autogen
apt-get install automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev
git clone https://github.com/fireworm71/veriumMiner
cd veriumMiner
apt-get install make
./build.sh

Fairly simple. All you have to do, after you have installed your preferred version of Linux, is login to Linux and run the commands. But hold that thought just for now. The first thing you will need to do is install UserLAnd.

UserLAnd is fairly straightforward. You download it from the Play Store and run it. Then you select which distribution you want. You don’t ever have to think about root privileges. For this experiment I decided to buy a cheap, discounted phone with Android 7. The CPU is a quad core 1.1GHz Cortex-A53. Not exactly a powerhouse, but it will do. There are potential issues with these cheap phones that could cause frustrations – but hold that thought, too.

A cheap Alcatel phone. Because it’s not going to be used for anything other than mining, I kept the plastic film over the screen instead of buying a more durable screen protector.

A suggestion before you begin: create a Google account just for your mining devices. I have a Gmail address for everyday communication, but I created another one just for this and future miners. If that email address somehow gets compromised, I won’t care so much. Remember that if you use YouTube, Google Docs etc, your account includes those. So keep your mining and personal accounts separate.

After you download and run UserLAnd, your screen will look similar to this:

Select Debian and give the app the required permissions.

Create a username, and for the sake of convenience, use the same password for your username as for VNC. Usually you wouldn’t do this, as it’s a security hazard. But you are just running a crypto miner, so it doesn’t matter.

Once you tap on a text field, the keyboard will appear, just like normal. The icons to the right of the password fields let you see the text you are typing. It’s wise to make use of that feature, as you aren’t asked to confirm your passwords.

When you are done, tap the blue checkbox at bottom right. You will see the Continue button.

Tap on Continue, and select SSH.

Once you do that, you will be taken to the login screen. It’s pretty much like any other Linux login screen you’ve seen that doesn’t have a graphical interface. Don’t worry about the text above the login prompt. I have no idea what it means, either.

After you have successfully entered your password, you will be logged in.

Now all you have to do is type in, or paste, the commands that install Fireworm. The easy way to do this is to send the commands to your preferred Gmail account that you can access on the device, and then copy and paste them into UserLAnd. I’m going to show you what that should look like before explaining what you’ll be doing.

You’ve noticed that there are a few differences with the list of commands listed near the beginning of this document. I’ve changed two things. Firstly, I’ve added the double ampersand between each command. This allows you to string together multiple commands that can run one after the other.

If you want to run the commands one at a time, you copy one command, paste it into the Linux command line interface (CLI), press return, and wait for it to run. For example, you might type ‘apt-get update’ into the CLI, then press return, and let it go until it completes. Then you would type ‘apt-get upgrade’, wait for that to complete, and then go on to the next command.

But I’ve strung them together, so you would type ‘apt-get update && apt-get upgrade’ and they would run one after the other. But I’ve also added an extra command in front of those: ‘sudo’. Sudo, in common language, lets the commands after it run as if they were typed by the superuser. But the cool thing is that you aren’t actually the superuser – it’s like getting most of the power of the superuser with the protection of normal user status. That is a little bit too technical for most of us, but all you have to know is that sudo lets you run commands with maximal potency and minimal risk.

The full list of commands now looks like this:

sudo apt-get update && sudo apt-get upgrade && sudo apt install git gcc g++ autogen && sudo apt-get install automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev && sudo git clone https://github.com/fireworm71/veriumMiner && cd veriumMiner && sudo apt-get install make && sudo ./build.sh

I didn’t need to use sudo for ‘cd veriumMiner’, as that simply changes the working directory to ~/veriumMiner.

However, just because you strung together a bunch of commands doesn’t mean that the commands behave differently. They behave exactly the same way as they would if you entered them one at a time. So if user input is needed, the system will wait until user input is given. Once you run the commands as written above, you will soon come across a prompt to type ‘y’ or ‘n’. This should happen twice:

Because we included the command ‘cd veriumMiner’, we are in the sub-directory, ~/veriumMiner.

Remember that we started in our home directory:

The tilde is a shortcut for your home directory. In this example, I chose the username of miner, so if I typed the command ‘pwd’ (‘print working directory’), the returned value would be ‘/home/miner/veriumMiner’.

So, back to the main exercise. We are now in the ~/veriumMiner directory:

If you typed the command ‘ls’, you should see a list of all the items in ~/veriumMiner:

At this point, the miner has been downloaded, including all the dependent software packages, and compiled. It’s ready to go. However, we do need to get to the business of setting up an account with a mining pool. Thankfully this is very easy. Because I use a pool called Beertendr, that’s the example I’ll be using here.

Because this sort of thing is not complicated, we will go through the process quickly. Firstly, click on ‘Sign Up’ at the top right of the screen.

Next, enter your details. For now, you do not need a coin address.

Then you set up your workers. In general, one device or computer uses one worker. In my case I have had up to three separate devices mining on Beertendr. Because of that, I have set up three workers. One for a PC, one for an old Samsung tablet, and one for the cheap Android phone. Your workers are visible by going to My Account -> My Workers.

You’ll notice that none of them are active at this point. Worker passwords aren’t crucial to account security as far as I know. In fact, many pools either don’t require them or don’t use them. I recommend using them anyway, if you have the option.

So now you have an account with a mining pool, and you have at least one worker. There are three variables derived from that: your mining pool username, a worker name and a password for that worker. The miner does not ever ask for your account password, as that is completely unnecessary. It should be obvious, but you do not need to be logged into your pool for your pool account to be active.

So, now we have two things: a mining pool account and an installed mining app. Let’s go back to the shell prompt and type in the command and variables that will get the miner working. It will look something like this:

If you’re not used to seeing that kind of input, have a look at it more closely:

./cpuminer -o stratum+tcp://stratum.beertendr.com:3334 -O username.workername:password

‘cpuminer’ is the command. The ‘./’ that precedes it tells Linux to run the following command (an executable file, or process, or application, or program) in the current working directory. Because cpuminer is not a part of the shell, you can’t just type it without the preceding dot-slash. The ‘-o’ specifies that the following variable will be the URL of the mining server. The ‘-O’ specifies that the following variables will be the username, workername and workername password, all in one statement.

Here is what I would type in to run cpuminer with my Beertendr account. My username is Panatomic, the workername is phone, and the workername has a password which is typed in after the colon. I have redacted the password:

There are some problems which you may encounter, depending on the phone you’re using. Sometimes when you copy and paste from an Android app into the Linux shell, the command may be 100% correct, but Linux returns an error. That’s because the system clipboard pastes extra characters into the shell that you may not notice. In this example, the clipboard pasted ‘\302\240’ (I blanked out the password) :

This was no doubt due to the fact that I typed the command into the notepad app and copied it from there. All you have to do is backspace part of the way, and then manually type the command to get it to work.

Assuming that everything was done correctly, once you tap enter, the miner should start. Mining crypto is full of frustrations, so be prepared to fail when you’re starting out. In fact, prepare to fail at all times. The rewards are not always going to seem worth it. But if you want to support the network, and earn some coins on the side, it is quite satisfying.

This is the sort of output you should see after you tap enter:

If you want to stop the miner, tap CTRL and then tap the c key. If the keyboard is hidden, just tap on the screen and it will appear. Linux will return ‘SIGINT received’ and you will be taken to the prompt.

You can run the miner in the background, or when the screen is locked. Most higher end phones should allow this by default. But on this phone that you see here, it’s not the case. It’s not a very high performance device, so by default, the miner will quit when you lock the screen or go to the home screen. However, there is a way around that. In settings, select Duraspeed, if it is available:

You will be given a number of options. The first thing to do is to deselect as many apps as you can. This will free up more resources for the miner. Or, at least, that’s what appears to be the case. Then, turn on Duraspeed:

Right, so because you turned on Duraspeed, the miner will continue to work when you are looking at other apps, or when the screen is locked. You may still get issues, however. In this case, Android is alerting me to the fact that the Maps app isn’t responding:

This is annoying, but it doesn’t necessarily have to mean that there is a problem with the miner. Just watch the screen, and if the miner appears to be working, you don’t have to do anything. Of course you probably should just tap on ‘Close app’ anyway. This may happen a lot, and you might get several alerts, stacked on top of each other. On certain occasions, the miner process will be killed, and you have to restart it. That’s actually easy to do, as you tap the up arrow key until the ./cpuminer… command comes up again, and then you just tap return.

And, perhaps every now and then, the process will be killed for no reason. But, maybe it’s just with cheap phones. I have a Samsung tablet from 2010 that has never shut down by itself. But its performance is so anemic that it’s almost not worth it except to test the concept. Thankfully it cost me very little money – a good example of taking an informed risk in op-shops.

Power consumption for most phones is very low, even though mining performance isn’t great either. But, higher end phones will offer much more performance and use either the same amount of electricity or only slightly more.

As an experiment, while the miner was running, I let the battery drain to 80%, then plugged in the phone’s charger to the mains. My domestic energy consumption meter returned a maximum of 3.8W. Then I turned off the screen and nothing changed. When the battery reached 100% charge, the energy meter returned the same value while the screen was on. Turning off the screen returned a maximum value of about 2.8W.

I hope to eventually write a similar tutorial for mining Monero with the new algorithm, Random X. For intermediate and expert users, that should be easy to do, based on the information I’ve outlined here. For those who aren’t so comfortable with this sort of thing, check back every couple of weeks, or just subscribe to the blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s