Beem Basics: Voting with several accounts in the same transaction

avatar


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 TransactionBuilder class.
  • 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 using getpass here to ask for the key interactively. Could also come from a python variable or an environmental variable...
  • tb.sign() and tb.broadcast() should be self-explaining

Any questions? Leave a comment!



0
0
0.000
3 comments
avatar

According to the Bible, How does the kingdom of heaven suffer violence as it is written in the Bible? ( Part 3 of 4)

(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)



Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to Thank you, our beloved friend.
Check our Discord Chat
Join our Official Community: https://beta.steemit.com/trending/hive-182074

0
0
0.000
avatar

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

You distributed more than 180000 upvotes. Your next target is to reach 185000 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

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