Beem Basics: Voting with several accounts in the same transaction

5개월 전

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[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:
            "voter": voter,
            "author": author,
            "permlink": permlink,
            "weight": weight

tb = TransactionBuilder()
tb.appendWif(getpass("Enter posting key: "))
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!

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:  trending

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!

Congratulations @stmdev! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

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