In my quest to write something that would make me richer, the thought of compounding my SPS Stake automatically came to mind.
Long ago, the Splinterlands team mentioned they may make this a feature of their site, but it never happened. Before I wrote this, I was manually staking my SPS several times a day, and frankly, it was a pain in the arse.

...'no need to click 'CLAIM' anymore, though you do need to install Python on your local computer to finally be done with all that'...
What better way to get rich than stake my SPS every minute? Think of the compounding, think of yesterday when your SPS was more valuable than today, think of watching the figures decrease over time making you bang your head on the nearest wall and have suicidal thoughts enter your head.
That's a bear market for you. If you can't stand all that shit, then you shouldn't be here. Since writing SPS Stake I have seen the value of my SPS daily income decrease from $9 to around $6.
It may well go lower, that's life and my head is slightly sore.
def get_balance(login_resp: dict, currency_token: str):
balance: float = 0
try:
for entry in login_resp.get("balances"):
if currency_token == entry.get("token"):
balance = entry.get("balance")
break
except TypeError:
print(Bcolors.RED + f"Node error getting balance, pausing for {delay} seconds.." + Bcolors.END)
return 0
return balance
There’s little point in re-inventing the wheel so I looked on GitHub to see if anyone had already written an SPS-Auto Staker. I found some code from @bauloewe from which I extracted some of his routines.
@bauloewe’s and another one I found were written in the days when the Airdrop was active and contained a lot more code than I needed. After wading through the code, I found the parts I needed and merged them into my own.
I contacted @bauloewe on discord and he kindly allowed me to use his routines after an explanation of what I was doing. I will add @bauloewe as a beneficiary of this post as 'compensation' although he told me the code was Open Source.
SPS Auto-Staker v.1.2 allows the SPS holder to claim their SPS every xx seconds. I have mine set to 60 which is every minute. Every claim will require Resource Credits (RC’s), so bear this in mind if you want to use the script, have lots of SPS but little Hive Power (HP).
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
The script is not perfect in any way and gets the SPS price from the hive.engine buybook, while it retrieves the HIVE price using the free CoinGecko API. I wanted to try both methods, and show usage examples of both.
spsprice = cg.get_price(ids='splinterlands', vs_currencies='usd', include_market_cap='true')
usdspsprice = spsprice['splinterlands']['usd']
I did find it odd that CoinGecko list SPS as Splinterlands. That threw me off for a while!
After editing the script and changing some variables to your own parameters, run it and it will show you several things. I like my scripts to be colourful, and show lots of data.
You will see the total value of your SPS Stake (which could result in severe depression), the approximate value of SPS you can claim per day (in HIVE), and the USD amount based on the HIVE value.
I was getting node problems which resulted in frequent TypeError errors when running this script and was forced to add a try: in the Get_Balance function. This seems to have fixed it, and I find it works for hours now.
I am still not convinced that the below code works, and auto-switches if there are node issues.
nodes = ['https://api.hive.blog', 'https://api.deathwing.me', 'https://anyx.io']
hive = Hive(node=nodes, keys=[posting_key])
set_shared_blockchain_instance(hive)
However, most problems go away if you simply re-try. It could be down to the first node in the list being hammered. I still get timeouts and errors with the above so added a try: in one of @bauloewe's routines.
The script is ready to download and run after modifying the variables as follows:
delay = 60
posting_key = '5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
username = 'your_username'
Ensure that the delay variable is set to how often you want to claim and stake your SPS. As I have a large SPS stash, I can manage around 0.191 SPS every minute.
While that's peanuts now when SPS was 50c a pop that was a mean 9c per minute. Those were the days, and I feel they may never return.
SPS Auto-Staker v.1.2 can be found on my personal GitHub Repository here.
Please feel free to comment and criticize my code. I am a beginner Python coder, so don't expect perfection.
FOOTNOTE: - Forgot to add @bauloewe as beneficiary and now it won't let me, how annoying. Will send him some HIVE after this pays out.
- Earn currency while you play brewing virtual beer with CryptoBrewMaster
- Earn currency while you play and become a global Rock Star with Rising Star
