From 5fa27b0a66046bf9ad62076a66de699c2dd67e91 Mon Sep 17 00:00:00 2001 From: Alexander Morris <qd01a@yourika.com> Date: Sun, 30 Jun 2019 13:41:16 -0400 Subject: [PATCH] Create wls_post.py wls v2.5 reward / posting example --- examples/wls_post.py | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 examples/wls_post.py diff --git a/examples/wls_post.py b/examples/wls_post.py new file mode 100644 index 00000000..ec73c1a3 --- /dev/null +++ b/examples/wls_post.py @@ -0,0 +1,70 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import sys +from datetime import datetime, timedelta +import time +import io +import logging + +from beem.blockchain import Blockchain +from beem.block import Block +from beem.account import Account +from beem.amount import Amount +from beemgraphenebase.account import PasswordKey, PrivateKey, PublicKey +from beem.steem import Steem +from beem.utils import parse_time, formatTimedelta +from beemapi.exceptions import NumRetriesReached +from beem.nodelist import NodeList +from beembase import operations +from beem.transactionbuilder import TransactionBuilder +log = logging.getLogger(__name__) +logging.basicConfig(level=logging.INFO) + +def test_post(wls): + op1 = operations.Social_action( + **{ + "account": "guest123", + "social_action_comment_create": { + "permlink": 'just-a-test-post', + "parent_author": "", + "parent_permlink": "test", + "title": "just a test post", + "body": "test post body", + "json_metadata": '{"app":"wls_python"}' + } + }) + + op2 = operations.Social_action( + **{ + "account": "guest123", + "social_action_comment_update": { + "permlink": 'just-a-test-post', + "title": "just a test post", + "body": "test post body", + } + }) + + op3 = operations.Vote( + **{ + 'voter': 'guest123', + 'author': 'wlsuser', + 'permlink': 'another-test-post', + 'weight': 10000, + }) + + privateWif = "5K..." + tx = TransactionBuilder(use_condenser_api=True, steem_instance=wls) + tx.appendOps(op1) + tx.appendWif(privateWif) + tx.sign() + tx.broadcast() + +if __name__ == "__main__": + # `blocking=True` forces use of broadcast_transaction_synchronous + wls = Steem(node=["https://pubrpc.whaleshares.io"], blocking=True) + print(wls.get_blockchain_version()) + print(wls.get_config()) + test_post(wls) + -- GitLab