New to Busy?

How to claim all pending token rewards at once - improved claim command

27 comments

holger80
72
last month2 min read

As most are active in more than one tribe, claiming all pending token at once would be handy. I improved the claim custom_json for scotbot so that all pending token can be given in an array:

Instead of

{"symbol": "TOKEN"}

a list with symbols can be given

[{"symbol": "TOKEN1"}, {"symbol": "TOKEN2"}]

The custom_json id is for both scot_claim_token

Python script to claim all pending token

from beem import Steem
from beem.nodelist import NodeList
import json
import six
import requests
import getpass

if __name__ == "__main__":

    
    if six.PY2:
        username = raw_input("Username: ")
    else:
        username = input("Username: ")

    url = "http://scot-api.steem-engine.com/@" + username
    r = requests.get(url)
    result = r.json()
    
    json_data = []
    for token in result:
        scot = result[token]
        if int(scot["pending_token"]) > 0:
            json_data.append({"symbol": token})
            print("%s can be claimed" % (token))
    
    if len(json_data) > 0:
        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])        
        stm.custom_json("scot_claim_token", json_data, required_posting_auths=[username])
    else:
        print("Nothing to claim")

In order to run this script, beem and steemengine must be installed:

pip install beem steemengine

When the script is saved as claim_all_scot.py
it can be run by

python claim_all_scot.py

The script asks for the username and checks of there is something to claim. When token can be claimed, it asks for the beem wallet password or for the posting key. One of both can be entered. Then the custom_json is broadcasted.

Comments

Sort byBest