With the cryptocurrency space being white-hot I've been very curious and learning all that I can. What better way to understand the core concepts than to start at the root of how cryptocurrency is generated aka mining. So here's some of what I've learned in the process of doing just that, hope you find it useful!
What is mining?
In the simplest terms, the act of mining serves two purposes. One, the miner is essentially providing book-keeping services for the crypto's public ledger aka blockchain by taking recent transactions every few minutes and writing them onto a page of the ledger referred to as a "block".
Although miners have to solve a puzzle / cryptographic function to be able to add their block to the blockchain, whoever is able to do this first, is rewarded with some crypto in exchange for their services.
This brings me to the second purpose, the crypto which is rewarded is considered "mined". This is essentially because it is new currency that's released to the network. All cryptocurrencies have a fixed number that is set to release to the network through this mining process.
As that unreleased currency dwindles down, miners are then incentivized by a reward attached to each transaction in the block. So the transactions that include this reward i.e transaction fee are likely to be processed faster.
Pick a currency
Now that we understand the high level concept behind mining, let's figure out what to mine. Naturally, BTC (Bitcoin) or ETH (Ethereum) would be our obvious candidates as they are the most well known and popular currencies at the moment. Although the issue with both is the fact that they are not very profitable to mine using a basic CPU or GPUs. If you are starting out, I'm assuming that's pretty much what you will have access to.
In most cases, the popularity of a currency has a direct correlation with it's mining difficulty. The more miners that join the pool, the faster new pages are written on the ledger. To keep the number of pages created steady, the difficulty of the puzzle is increased at a regular interval.
So out of the top 10 currencies on coinmarketcap.com, the best candidate for CPU or GPU mining would be XMR (Monero) since it's based on a proof-of-work algorithm called CryptoNight which is designed to be suitable for ordinary CPU and GPUs and is resistant to mining with special hardware i.e ASIC. So having said that, let's pick XMR. If you need some more convincing, here's a good list of why XMR is a good bet.
Setup a wallet
So the next thing we'd have to figure out is where to store the proceeds from the mining. For XMR, the options are somewhat limited since it's still a currency in development. The best bet would be to download & install the official wallet.
Alternatively, you can setup an account in one of the online exchanges like Bittrex or Kraken and use their built-in wallet, although it's not recommended to use that as a long term storage for large amounts of currency.
Once you have this setup, take note of your wallet's address. We will need this in the next steps.
Join a pool
So while XMR is friendly to solo mining, the chances of earning a reward are low. So in order to boost our chances, we'll want to share our processing power in a network of other miners. We can then earn our reward according to the amount of hashing power we contributed towards creating a block.
There are several XMR mining pools that you can choose from this list. I would recommend sticking to xmrpool.net if you are in US or moneropool.com if you are in Europe.
Both have a good balance of # of miners and the hash rate. You don't want to join a pool with a lot of miners because your earnings can get very diluted, you'll want to stick to a good balance between hashing power and the # of members in a pool.
Start mining
So now we are finally ready to start mining. We have two options, we can either use the CPU or the GPU to do the mining. Let's look at both the options and how they work.
CPU
ServeTheHome has put together some awesome Docker images to make this easy. You can install Docker for your platform if you haven't already and run this command:
For xmrpool.net:
sudo docker run -itd -e username=[YOUR_WALLET_ADDRESS] servethehome/monero_cpu_xmrpooldotnet
For moneropool.com:
sudo docker run -itd -e username=[YOUR_WALLET_ADDRESS] servethehome/monero_cpu_moneropool
GPU
Again huge thanks to ServeTheHome for providing images for Nvidia GPUs which makes GPU mining super simple without having to install CUDA dependencies on your machine.
Although what you will need to install is nvidia-docker so the Docker container can utilize your GPU.
Installation on Ubuntu should be pretty straightforward:
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi
Checkout installation steps on their repo for other distros. Once you have that working you can spin up the Docker instance:
For xmrpool.net:
NV_GPU=0 nvidia-docker run -itd -e username=[YOUR_WALLET_ADDRESS] --name GPU0_monero servethehome/monero_gpu_nv_xmrpooldotnet
For moneropool.com:
NV_GPU=0 nvidia-docker run -itd -e username=[YOUR_WALLET_ADDRESS] --name GPU0_monero servethehome/monero_gpu_nv_moneropool
If you have multiple GPUs you will need to add NV_GPU=0
prefix as shown above and spin up additional containers for each GPU you want to target. If you only have one, you can skip the prefix and explicit names.
Conclusion
Depending on your hardware and pool you might have to wait a day or so to see some rewards come your way. You can checkout this calculator to figure out what kind of return you can expect based on different variables.
Your best bet is to run this on a spare machine and leave it on for few days. You are probably not going to become the next crypto millionaire but it's an excellent opportunity to learn more about the crypto space and Docker containers.
The modern day crypto gold rush reminds me a little of Charles Nahl's "Miners in the Sierras"
May the odds be with you!
This post was originally published on my blog. If you liked this post, please share it on social media and follow me on Twitter!
Top comments (13)
Cryptocurrencies are the coffee capsules of the computer science world. They are not necessary and they are pretty bad in terms of wasting energy and resources... Please don't waste energy on that stuff. Can't believe people really do this...
Sigh, I bought a ant miner from overseas, didn't receive it for 3months. Was too noisy to run and lost money on sale of item. The cost of electricity and internet speed can factor into 24/7 mining. By the sounds of it you are doing well with it. Personally, I wouldn't touch it with a barge pole as Australia has high electric and shit internet. Sometimes I swear, the almighty gods don't want me to have money
Oh yeah buying a mining rig is tempting but probably not profitable unless you are someplace where electricity is dirt cheap or mining some obscure coin and counting your luck.
I'm really not making any profit on it either. I mainly see it as a tool to learn more about crypto. Unless you have a beefy spare machine or can build a rig with relatively low cost forget about profits. You will have better luck just trading on exchanges.
You would like this YouTube guy siraj, he talks about using decentralization with crytocurrency erthereum. What I understand by the concept is a the data is more peer to peer reducing bottle necks from major servers like say netflix and then incorporates crytocurrency to pay each user for their contribution to the decentralised network. Why over my head coding wise but you may find it interesting. :)
Nice, will check it out, looks like he has some interesting videos!
I tried this on mac but for any reason I'm not able to get the daemon running, seems it's updating the blocks because the logs says I'm 1700 days behind. Reading somewhere it says better to download the binary files (23gb) and sync it manually.
Will Try and write here later, hope I works, after reading abount minergate don't think I could use it
Yeah, syncing is slow, I had to keep it running overnight to get it done. Manual syncing sounds like a good option.
did it! but... still unable to connect to the daemon, so after sync everything...no mining.
What subdomain of cryptocurrency is the most interesting to you?
I think developing commercial solutions using the blockchain is very interesting/promising. Although I'm sure there are a lot of challenges that need to be overcome before we see widespread adoption.
My next deep dive is probably going to be looking at various strategies for scaling the blockchain and maybe even messing around with Solidity / Smart Contracts in ETH.
Isn't this even simpler? minergate.com
Yeah arguably simpler although they've been accused of being part of some scams and "stealing" your hashrate. They are also close-sourced so no way to verify what's going on. Besides what's the fun in doing it the easy way? ;)
I've heard the same rumours indeed, but when you're just starting, it's nice to see a Hashrate displayed in less than 1 minute. Anyway, any pool has the theoretical power of stealing your hashrate, right?
I agree for the fun. :-)