Skip to content

Instantly share code, notes, and snippets.

@emre emre/voting.py Secret
Last active Apr 16, 2019

Embed
What would you like to do?
3rd party voting on dpoll
import json
import uuid
import requests
from steem import Steem
from steem.transactionbuilder import TransactionBuilder
from steembase import operations
# configuration
voter = "<voter_username>"
s = Steem(keys=["<private_key>"])
poll_author = "steemalliance"
poll_permlink = "steem-alliance-structure-proposal-election"
votes = [
'“DeCentraSteem” Submitted By @impactn',
]
ops = [
operations.Comment(**{
"author": voter,
"body": 'Voted for \n - %s' % votes[0],
"permlink": str(uuid.uuid4()),
"parent_permlink": poll_permlink,
"parent_author": poll_author,
"json_metadata": json.dumps({
"content_type": "poll_vote",
"votes": votes,
"tags": ["dpoll", ]
}),
"title": "",
}),
]
tb = TransactionBuilder()
tb.appendOps(ops)
tb.appendSigner(voter, "posting")
tb.sign()
resp = s.broadcast_transaction_synchronous(tb)
# trigger dpoll to register the vote it's own database
r = requests.get("https://dpoll.xyz/web-api/sync", params={
"block_num": resp["block_num"],
"trx_id": resp["id"]
})
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.