Posts
How to stake all SCOT at once
25
@holger80
·0 views
2 min read
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")