Skip to content

Instantly share code, notes, and snippets.

@emre

emre/voting.py Secret

Last active April 16, 2019 10:28
Show Gist options
  • Save emre/16e561b416de0e9f7fefc701e673d696 to your computer and use it in GitHub Desktop.
Save emre/16e561b416de0e9f7fefc701e673d696 to your computer and use it in GitHub Desktop.
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