Hello and welcome to another installment of Awesome Self Hosted!
Updated March 12th, 2021 - allow unlocking encrypted wallets, simplified usage, solo mining
Today we are going to be looking at mining WebDollar (WEBD) in a container. This tutorial will go over running this miner directly in Docker, and also provide a mechanism to deploy this to a personal / self hosted Kubernetes cluster.
For those who don't know, WebDollar is a lesser-known cryptocurrency with a bold mission to become the currency of the internet. Their technology is awesome, and it enables anybody the ability to mine. They use an ASIC resistant and GPU unfriendly proof-of-work algorithm (PoW), in addition to proof-of-stake (PoS) to save your hardware from needing to run PoW problems constantly. At the time of this writing WEBD is 90% PoS and 10% PoW.
WebDollar might be the easiest cryptocurrency to mine out there, because they make the setup so user friendly. Simply open their website, https://webdollar.io, and under the covers this will create a wallet for you and let you decide how much of your CPU you would like to allocate to PoW mining. Do note that it may take a few hours for you to start seeing coins in your wallet, as without any coins starting, you cannot participate in PoS (100 WEBD minimum), and when the pool you are mining in wins a coin, it takes about an hour for these funds to be paid out.
Here's some statistics on the WEBD coin:
With how easy this coin is to work with, why wouldn't you give this a try? If nothing else, hopefully you'll learn something from experimenting with this coin, and, if we're lucky, WEBD may be worth something substantial one day! 😃
Mining in a Container
To be able to mine WEBD in a container, there's only a few requirements.
- Visit the WebDollar website and create your wallet.
- Download your wallet (and password text file, if applicable - recommendation lock your wallet).
- Download and install Docker for your OS.
We'll be using this project to mine WEBD in a container. Author's disclaimer, I am the creator of this container. The latest version of the container is published on this GitHub page.
This project was forked from another WEBD miner and then I added a few enhancements.
- Updated the container to be based off Ubuntu 20.04(LTS)
- Used the official WEBD install script to set up the miner
- Added support for PoS mining with a locked wallet
- Incorporated a mechanism to build the container weekly, with the current latest release version of WebDollar.
- NOTE: There is a tipping mechanism built into this project, but it is entirely optional. If I've provided you with an amazing experience, feel free to show your support by running this container with tipping mode on:
ENABLE_TIPS=true- if not, I still hope you enjoy this container and blog post!
This container is based off a few optimizations I have committed to the WEBD source code, and if this container is great for you, I encourage you to run this container with tips enabled (even if only for a small amount of time) - this will leverage the WEBD referral system to send a small percentage of mined coins to me.
To launch this container, simply run this command, substituting the path to your downloaded wallet for the WALLET variable, and the mining pool you want to use for the MINING_POOL_URL.
docker run -e MINING_POOL_URL='https://webdollar.io/pool/1/CanadianStakePool/0.02/ea115a560322c557d3617732145a837af9992d729e5f8165d3b7077b22ee12a4/https:$$webdollarpool.ca:443' \
-e WALLET=$(cat ~/Downloads/WEBD\$281adac6ed21a1af5d6f8af34bb78d4cf87bf43a.webd) \
-e PASSWORD_PHRASE=$(cat ~/Downloads/path/to/password.txt) \
-e ENABLE_TIPS=true \
-d --name webdollar-miner \
bwvolleyball/webdollar-miner-container:1.3.02
I've been using the CanadianStakePool you see here, however you can use any pool you like
As of March 12th, 2021 - you no longer need to escape $ in the mining pool URL due to improvements in the container.
To inspect the logs from the container at any time to see how it's doing, just run
docker logs -f webdollar-miner
If you want to launch this container in the foreground, replace -d with -it in the run command.
Congratulations 🎉 - at this point, you are mining in a Docker container! However, this blog hasn't achieved everything we've set out to achieve. If you want to take it one step further and run this in Kubernetes, read on!
Mining on Kubernetes
Do note that many cloud providers have rules and regulations about crypto mining on their infrastructure, you are responsible for reading the rules and knowing the regulations of your Kubernetes provider. For myself, I run a self-hosted Kubernetes cluster in my basement 😜, anything is allowed!
This mining setup will only use ephemeral disk storage that is attached to the Kubernetes pod. This container definition is quite easy, and only needs the same pieces set up as when we were mining via docker. The difference will be that we will keep the WEBD wallet as a Kubernetes secret. All items will be added to the crypto namespace
You can play around with the settings you allocate to your WEBD miner, for this example, I am going to show how to set up the same miner we did above, with 1 CPU and 1 GB of memory.
First things first, let's add our WEBD wallet to our cluster
kubectl create secret generic webd-wallet \
--from-file=wallet=/path/to/WEBD\$281adac6ed21a1af5d6f8af34bb78d4cf87bf43a.webd \
-n crypto
*Notice, this is the same wallet we used in the Docker container above.
If your wallet is encrypted, you will also need to make a secret for the password.
kubectl create secret generic webd-wallet-password \
--from-file=password=/path/to/password.txt \
-n crypto
The secret is named webd-wallet, and the key is named wallet. It is possible to create a secret containing many wallets, in-case you want to mine in multiple pools. In fact, my intention is to do just this, with one miner focused on PoW with more resources, and a second miner focuses on PoS with fewer resources.
Now for the deployment, save this file and then run kubectl apply -f webdoller-miner.yaml
webdoller-miner.yaml
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: webdollar-miner
namespace: crypto
spec:
replicas: 1
#number of replicas generated
selector:
#assigns labels to the pods for future selection
matchLabels:
app: webdollar-miner
template:
metadata:
labels:
app: webdollar-miner
spec:
containers:
- name: webdollar-miner
image: bwvolleyball/webdollar-miner-container:1.3.02
env:
- name: MINING_POOL_URL
value: 'https://webdollar.io/pool/1/CanadianStakePool/0.02/ea115a560322c557d3617732145a837af9992d729e5f8165d3b7077b22ee12a4/https:$$webdollarpool.ca:443'
- name: WALLET
valueFrom:
secretKeyRef:
name: webd-wallet
key: wallet
- name: PASSWORD_PHRASE
valueFrom:
secretKeyRef:
name: webd-wallet-password
key: password
- name: ENABLE_TIPS
value: 'true'
resources:
limits:
memory: "1Gi"
cpu: "1000m"
And that's it! if everything went well, you are mining webdollar on your Kubernetes cluster!
You can check it with the following command:
kubectl get deployments -n crypto
NAME READY UP-TO-DATE AVAILABLE AGE
webdollar-miner 1/1 1 1 3m27s
Grab the logs from your webdollar pod in order to verify everything is working. Unless it's a PoW block, your hash rate will be very small by default. If you get hashes/s in your logs, everything is connected and functional.
⇒ kubectl logs --selector=app=webdollar-miner -n crypto
⚠ Transactions stack - 0 after removing old
pools New Work: 0 starting at: 0 block: 0000000000000000000000000000000000000000000000000000
pools Push Work: (0)000000068701eeabe3903288e54b5558936069d0ad88cef596a982044a7dee44 id: 21488
pools timestamp 90517604 balance 20448.4165
pools Statistics: Real 0 h/s
pools New Work: 0 starting at: 0 block: 0000000000000000000000000000000000000000000000000000
⚠ Transactions stack - 0 after removing old
24 hashes/s
1 hashes/s
1 hashes/s
1 hashes/s
1 hashes/s
1 hashes/s
How am I using all these things?
I am primarily running my WebDollar Kubernetes miner for PoS mining, and have purposefully not allocated much power to this container. The idea behind this is to achieve interest on my current WEBD stake.
Solo Mining
Lastly, it is possible to use this container for solo mining. Although, if you are just starting out, I do not recommend this. In order for this project to be fully supportive of WebDollar mining, I felt it only right to support this aspect as well.
Solo mining will take a lot longer to initialize, since the container will first need to download and unzip the latest snapshot of the blockchain, along with any blocks that have been mined since that snapshot. Only after your miner has caught up to the head of the blockchain will it start mining.
Enabling in Docker
To enable this in docker, simply add -e SOLO_MINING=true to your mining command.
Enabling in Kubernetes
To enable this in Kubernetes, add this snippet to the env: section:
- name: SOLO_MINING
value: 'true'
If this blog post has been helpful, be sure to like it, tip it, or subscribe. I'm on a mission to share and document my whole home Kubernetes install! If you have a question for me, or want to know how I've handled something, be sure to drop me a comment and I'll be happy to explain.