Solo mining: Get block notifications through your own telegram bot!

Hi guys,

I’ve been solo mining for a bit and thought it would be super cool to get Telegram notifications when you find a block, so I created a script for it. Here are the instructions to set this up yourself, it shouldn’t be too hard:

  • Go to your Telegram app and add @BotFather.
  • Type /start in the chat with the @BotFather bot.
  • Type /newbot and follow the instructions until you’ve finished creating your bot, then you will get a token.
  • Search your own bot by using the username you have given it in in the previous step.
  • Type /start in the chat of your own bot, and then type anything else after that.
  • Go to https://api.telegram.org/bot<yourtoken>/getUpdates in your browser, and replace <yourtoken> in the url with the token you got earlier.
  • In the response you should see an id field, which is a large number, you will need this.
  • Now create a script, let’s call it run_with_notifications.sh and copy the below code into it.
#!/bin/bash

TOKEN="<yourtoken>"
CHATID="<yourchatid>"
KERNELPATH="/path/to/aion/kernelfolder"
ACC="<youraddress>"
MSG="Block found! New balance: "

while read -r LINE; do
        echo ${LINE}
        if [[ ${LINE} = *"Share accepted"* ]]; then
			RESPONSE=$(curl -H "Content-Type: application/json" -d "{\"method\": \"eth_getBalance\", \"params\":[\"$ACC\", \"latest\"]}" -X POST localhost:8545)
			HEX=$(echo $RESPONSE | grep -Po '"result":.*?[^\\]",' | awk -F':"' '{print $2}' | tr -d '",')
			DEC=$(cd $KERNELPATH/web3 && node -e "console.log(require(\"./lib/utils/utils.js\").toDecimal(\"$HEX\"))")
			BALANCE=$(cd $KERNELPATH/web3 && node -e "console.log(require(\"./lib/utils/utils.js\").fromWei($DEC))")
			curl --data chat_id="$CHATID" --data-urlencode "text=$MSG$BALANCE" "https://api.telegram.org/bot$TOKEN/sendMessage" > /dev/null
        fi
done < <(./run_quickstart.sh)
  • Replace <yourtoken> by your own token you acquired above.
  • Replace <yourchatid> with the chat id you acquired above.
  • Replace /path/to/aion/kernelfolder with the full path to the folder where you have the kernel installed.
  • Replace <youraddress> with the address you use for mining.
  • Don’t forget to make the script executable (chmod +x run_with_notifications.sh).
  • Also make sure you have NodeJS and npm installed and run npm install in the web3 folder of your kernel installation.
  • Now add this script to the folder where you have the solo_pool installed and from now on use this to start the solo_pool instead of run_quickstart.sh.

Note that I still the the ‘old’ solo_pool instead of the new pool, which is perfectly fine for solo mining.

Hopefully you find this as useful as me. It’s nice to track when exactly you find your blocks and to keep an easy eye on your coins. Good luck mining!

10 Likes

Thanks Jim for making and sharing this. I’ll give a try when I get home. will be very useful and exciting.:+1:

1 Like

Super cool! … I think my 1.2k sols isn’t big enough to solo anymore - wish I had this when I was though!

I’m at half that right now, why isn’t that enough to solo mine?

Im at just below 1k sols, profit solo has been better than with a pool. Although I might try one again soon

Check out our 0% fee PPLNS pool! You won’t regret it!

We have started a community friendly Aion pool using Aion’s pool software.

You can check out our pool site at http://glorypool.io/

You can use this sample address if you are using smartminer

./SmartMiner.v3.1 -cd 0 1 2 3 4 5 -l glorypool.io:3333 -u (your public address)

We currently have 0% mining fee and is hosted on digitalocean for virtually no downtimes based in North America

Check this article, it helped me too, i hope you will also get some help form here