def test_custom_json(self): op = operations.CustomJson( **{ "json": [ "reblog", OrderedDict( [ # need an ordered dict to keep order for the test ("account", "xeroc"), ("author", "chainsquad"), ("permlink", "streemian-com-to-open-its-doors-and-offer-a-20-discount" ) ]) ], "required_auths": [], "required_posting_auths": ["xeroc"], "id": "follow" }) ops = [operations.Operation(op)] tx = SignedTransaction(ref_block_num=ref_block_num, ref_block_prefix=ref_block_prefix, expiration=expiration, operations=ops) tx = tx.sign([wif], chain=self.steem.chain_params) tx_wire = hexlify(bytes(tx)).decode("ascii") compare = ("f68585abf4dce7c8045701120001057865726f6306666f6c6c" "6f777f5b227265626c6f67222c207b226163636f756e74223a" "20227865726f63222c2022617574686f72223a202263686169" "6e7371756164222c20227065726d6c696e6b223a2022737472" "65656d69616e2d636f6d2d746f2d6f70656e2d6974732d646f" "6f72732d616e642d6f666665722d612d32302d646973636f75" "6e74227d5d00011f0cffad16cfd8ea4b84c06d412e93a9fc10" "0bf2fac5f9a40d37d5773deef048217db79cabbf15ef29452d" "e4ed1c5face51d998348188d66eb9fc1ccef79a0c0d4") self.assertEqual(compare[:-130], tx_wire[:-130])
def custom_json(self, id, json, required_auths=[], required_posting_auths=[]): """ Create a custom json operation :param str id: identifier for the custom json (max length 32 bytes) :param json json: the json data to put into the custom_json operation :param list required_auths: (optional) required auths :param list required_posting_auths: (optional) posting auths """ account = None if len(required_auths): account = required_auths[0] elif len(required_posting_auths): account = required_posting_auths[0] else: raise Exception("At least one account needs to be specified") op = operations.CustomJson( **{ "json": json, "required_auths": required_auths, "required_posting_auths": required_posting_auths, "id": id }) return self.finalizeOp(op, account, "posting")
def cancelorder(cardid): # ermittele die market_id r = requests.get('https://steemmonsters.com/market/for_sale') data = r.json() for card in data: uid = card['uid'] market_id = card['market_id'] if cardid == uid: trxid = market_id #baue die Transaktion auf json = {"trx_id": trxid} print(json) ops = [ operations.CustomJson( **{ "from": user, "id": "sm_cancel_sell", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def cancel_match(): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_cancel_match", "json": '{"app":"steemmonsters/0.4.4.1"}', "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign()
def smshowteam(show_json): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_team_reveal", "json": show_json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def smfindmatch(): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_find_match", "json": '{"match_type":"Ranked"}', "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def start_quest(): json = '{"type":"daily"}' ops = [ operations.CustomJson(**{ "from": user, "id": "sm_start_quest", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def dw_attack(enemy, unit, amount, account): ops = [ operations.CustomJson(**{ "from": account, "id": "dw-attack", "json": { "username" : account, "defender":enemy, "army":[{ "unit": unit, "amount":amount }] }, "required_auths": [], "required_posting_auths": [account], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(account, "posting") tb.sign() pprint.pprint(tb.broadcast())
def claimreward(): #get the claim id # get the current quest data r = requests.get('https://steemmonsters.com/players/quests?username='******'id'] json = '{"type":"quest","quest_id":"' + claimid +'"}' ops = [ operations.CustomJson(**{ "from": user, "id": "sm_claim_reward", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def sell(cardid, price): json = [{ "cards": [cardid], "currency": "USD", "price": str(price), "fee_pct": 500 }] print(json) ops = [ operations.CustomJson( **{ "from": user, "id": "sm_sell_cards", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
from steem import Steem from steem.transactionbuilder import TransactionBuilder from steembase import operations s = Steem(nodes=["https://rpc.usesteem.com"], keys=[posting_key]) account = account_name ops = [ operations.CustomJson( **{ "from": account, "id": "dw-heist", "json": { "username": account, "amount": "100" }, "required_auths": [], "required_posting_auths": [account], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(account, "posting") tb.sign() tb.broadcast() #from steem import Steem #from steem.transactionbuilder import TransactionBuilder #from steembase import operations #s = Steem(nodes=["https://rpc.usesteem.com"], # keys=["<posting_key>"])
#shipList = { "corvette": { "pos": 1, "n": 2 } } x = 241 y = -41 s = Steem(keys=[postingPK]) ops = [ operations.CustomJson( **{ "from": account, "id": "nextcolony", "json": { "username": account, "type": "attack", "command": { "tr_var1": { shipName: { "Pos": 1, "N": shipCount } }, "tr_var2": x, "tr_var3": y, "tr_var4": myPlanet } }, "required_auths": [], "required_posting_auths": [account], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(account, "posting")