Beem Basics: Voting with several accounts in the same transaction
Image: @creativista
Most of us have more than one account, especially since the tribes are around. There are situations, where it can be helpful to have them all vote for the same post. I use this for flags, for example, since I can make use of all my SP distributed across multiple accounts - plus the tribe stake - to do my tiny share to discourage abuse.
The typical situation with one voter is, that there is one vote operation in one transaction that is signed by one private key. In order to have several vote operations in one transaction, they must still be signed by one private key. This means that there must be one private key that has posting permission for all accounts that I want to use that way. I've set account based posting authority for mine, e.g. via https://beta.steemconnect.com/authorize/[accountname] or via beempy. Once this is there, here's the script:
from beem.transactionbuilder import TransactionBuilder
from beembase import operations
from getpass import getpass
accounts = ['acc1', 'acc2', 'acc3']
author = "bad-author"
permlink = "bad-post"
weight = -10000 # -100% flag - value needs to be multiplied by 100
ops = [] # collect all vote operations in a list
for voter in accounts:
ops.append(operations.Vote(
**{
"voter": voter,
"author": author,
"permlink": permlink,
"weight": weight
}))
tb = TransactionBuilder()
tb.appendOps(ops)
tb.appendWif(getpass("Enter posting key: "))
tb.sign()
tx = tb.broadcast()
print("Flagged @%s/%s with %s with %.2f%%" % (author, permlink, ", ".join(accounts), weight/100))
Remarks / Comments
- Several operations in the same transaction can be realized with the
TransactionBuilderclass. - This class takes a list of blockchain operations to be signed
- for that, I'm queuing all vote operations and add them to the TransactionBuilder instance via
tb.appendOps() - Steem internally calculates with vote percentages multiplied by 100: a vote weight of 1 means a 0.01% vote, a vote weight of 10000 means a 100% vote.
appendWif()assigns the private key to the TransactionBuilder instance - this is only needed if the corresponding private key is not stored in beem's internal wallet. I'm usinggetpasshere to ask for the key interactively. Could also come from a python variable or an environmental variable...tb.sign()andtb.broadcast()should be self-explaining
Any questions? Leave a comment!
Leave Beem Basics: Voting with several accounts in the same transaction to:
Read more #python posts
Best Posts From stmdev
We have not curated any of stmdev's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From stmdev
- Overview of Steem/HiveEngine Tokens - which tags are enabled on Steem, which on Hive
- Getting Started with Ada - Dockerized Programming Environment
- Beem Basics: Voting with several accounts in the same transaction
- Beem Basics: Downloading a Day of Steem Blockchain Data
- Curves and Reward Distribution across Author and Curators for the Tribes
- Fetching account data from all Steem accounts from the Blockchain with beem/python
- How to find all exchange transfers with a given memo with python
- PALNet test post
- Finding the number of authors/voters/... per day with Python
- Drugwars frontent was showing too low balances wrt to the Operation Center level