How to stake all SCOT at once

in scot •  2 months ago 

I wrote a small script that will stake all SCOT at once. You can edit the array and exclude tokens from automatic staking:

    scot_token = ["PAL", "SPORTS", "ZZAN", "NEOXAG", "LEO", "SPT", "BATTLE", "GG", "LIV", "MARLIANS", "SCT",
                  "ACTNEARN", "CCC", "LASSECASH", "AAA", "MOT", "STEM", "JAHM", "WEED", "INT", "IV",
                  "BLQ"]

Just remove the symbol which should not be staked.

Script

Save the following code as stake_all_scot.py or any other name.

from beem import Steem
from beem.nodelist import NodeList
from steemengine.wallet import Wallet
import json
import six
import requests
import getpass

if __name__ == "__main__":

    scot_token = ["PAL", "SPORTS", "ZZAN", "NEOXAG", "LEO", "SPT", "BATTLE", "GG", "LIV", "MARLIANS", "SCT",
                  "ACTNEARN", "CCC", "LASSECASH", "AAA", "MOT", "STEM", "JAHM", "WEED", "INT", "IV",
                  "BLQ"]

    if six.PY2:
        username = raw_input("Username: ")
    else:
        username = input("Username: ")
    wallet = Wallet(username)
    stake_token = {}
    for scot in scot_token:
        data = wallet.get_token(scot)
        if data is not None and data["balance"] is not None:
            balance = float(wallet.get_token(scot)["balance"])
            if balance > 0:
                stake_token[scot] = balance
    if len(stake_token) > 0:
        
        print("Will stake the following token %s" % str(stake_token))
        ret = ""
        while ret not in ["y", "n"]:
            if six.PY2:
                ret = raw_input("continue? (y/n)")
            else:
                ret = input("continue? (y/n)")
        if ret == "y":
            
            nodes = NodeList()
            nodes.update_nodes()
            stm = Steem(nodes.get_nodes())    
            pwd = getpass.getpass("Enter Walletpassword or posting key for %s" % username) 
            
            try:
                stm.unlock(pwd)
            except:
                stm = Steem(node=nodes.get_nodes(), keys=[pwd])
            json_data = []
            for token in stake_token:
                
                contract_payload = {"symbol":token.upper(),"quantity":str(stake_token[token]), "to":username}
                json_data.append({"contractName":"tokens","contractAction":"stake",
                                     "contractPayload":contract_payload})
            # print(json_data)
            tx = stm.custom_json("ssc-mainnet1", json_data, required_auths=[username])
            print(tx)
    else:
        print("Nothing to stake")

Setup python

You need beem and steemengine in order to run the script

pip install beem steemengine -U

Replace pip with pip3 if you are using python3 (recommended).

The beem wallet can be setup by

beempy createwallet
beempy addkey

Runing the script and claim all tokens

python stake_all_scot.py

Enter now the username, confirm with y and enter either the wallet password or the active key.

Server version

This version does not ask for input and can be run at a server

from beem import Steem
from beem.nodelist import NodeList
from steemengine.wallet import Wallet
import json

if __name__ == "__main__":

    scot_token = ["PAL", "SPORTS", "ZZAN", "NEOXAG", "LEO", "SPT", "BATTLE", "GG", "LIV", "MARLIANS", "SCT",
                  "ACTNEARN", "CCC", "LASSECASH", "AAA", "MOT", "STEM", "JAHM", "WEED", "INT", "IV",
                  "BLQ"]

    username = "holger80"
    # Set either the active wif or the wallet password
    wif = "5xxx"
    wallet_password = None
    
    wallet = Wallet(username)
    stake_token = {}
    for scot in scot_token:
        data = wallet.get_token(scot)
        if data is not None and data["balance"] is not None:
            balance = float(wallet.get_token(scot)["balance"])
            if balance > 0:
                stake_token[scot] = balance
    if len(stake_token) > 0:
        
        print("Will stake the following token %s" % str(stake_token))
            
        nodes = NodeList()
        nodes.update_nodes()
        stm = Steem(nodes.get_nodes())    
        pwd = getpass.getpass("Enter Walletpassword or posting key for %s" % username) 
        
        if wallet_password is not None:
            stm.unlock(wallet_password)
        else:
            stm = Steem(node=nodes.get_nodes(), keys=[wif])
        json_data = []
        for token in stake_token:
            
            contract_payload = {"symbol":token.upper(),"quantity":str(stake_token[token]), "to":username}
            json_data.append({"contractName":"tokens","contractAction":"stake",
                                 "contractPayload":contract_payload})
        # print(json_data)
        tx = stm.custom_json("ssc-mainnet1", json_data, required_auths=[username])
        print(tx)
    else:
        print("Nothing to stake")
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Looks complicated. How about making it easy

Like an option in steem engine

This post earned a total payout of 0.073$ and 0.055$ worth of author reward which was liquified using @likwid. To learn more.

Tried it, but confusing

So you have to do this every single time you want to stake?

looks good but not easy to use:D

Congratulations @holger80! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 12000 upvotes. Your next target is to reach 13000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

apply to steem-engine menu to easily use in mobile also plz 💙

Posted using Partiko Android

Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 7.553 which ranks you at #52 across all Steem accounts.
Your rank has improved 1 places in the last three days (old rank 53).

In our last Algorithmic Curation Round, consisting of 164 contributions, your post is ranked at #2. Congratulations!

Evaluation of your UA score:
  • Your follower network is great!
  • The readers appreciate your great work!
  • Great user engagement! You rock!

Feel free to join our @steem-ua Discord server

Hi, @holger80!

You just got a 4.11% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

how to install steem on termux, android python?

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

😱 Is there a way to list all the current tokens instead of hard coding them? Great job by the way. I’m currently doing mine in JS.

Posted using Partiko iOS