def buy_upvote(author, upvote_bot, amount, permlink): transfers = [{ 'from': author, 'to': upvote_bot, 'amount': '{0:.3f} SBD'.format(amount), 'memo': 'https://steemit.com/@{}/{}'.format(author, permlink) }] print("\n\n") print("Buying " + upvote_bot + " " + str(amount) + " vote for author " + author + "\n and permalink " + permlink) print("\n\n") tb = TransactionBuilder() operation = [operations.Transfer(**x) for x in transfers] tb.appendOps(operation) tb.appendSigner(author, 'active') tb.sign() try: tx = tb.broadcast() print("** Vote success") except Exception as error: print(repr(error))
def payout(transfers, account): print("Paying out winners") tb = TransactionBuilder(no_broadcast=False) operation = [operations.Transfer(**x) for x in transfers] tb.appendOps(operation) tb.appendSigner(account, 'active') tb.sign() tx = tb.broadcast() print("Payout succes")
def transfer(_from, _to, amount): messages = [{'from': _from, 'to': _to, 'amount': amount, 'memo': ''}] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.Transfer(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(_from, 'posting') tb.sign() tx = tb.broadcast() print(tx)
def transfer(self, to, amount, asset, memo="", account=None): """ Transfer SBD or STEEM to another account. :param str to: Recipient :param float amount: Amount to transfer :param str asset: Asset to transfer (``SBD`` or ``STEEM``) :param str memo: (optional) Memo, may begin with `#` for encrypted messaging :param str account: (optional) the source account for the transfer if not ``default_account`` """ if not account: account = configStorage.get("default_account") if not account: raise ValueError("You need to provide an account") assert asset in ['STEEM', 'SBD'] if memo and memo[0] == "#": from steembase import memo as Memo memo_wif = self.wallet.getMemoKeyForAccount(account) if not memo_wif: raise MissingKeyError("Memo key for %s missing!" % account) to_account = Account(to, steemd_instance=self.steemd) nonce = random.getrandbits(64) memo = Memo.encode_memo( PrivateKey(memo_wif), PublicKey(to_account["memo_key"], prefix=self.steemd.chain_params["prefix"]), nonce, memo, prefix=self.steemd.chain_params["prefix"]) op = operations.Transfer( **{ "from": account, "to": to, "amount": '{:.{prec}f} {asset}'.format( float(amount), prec=3, asset=asset), "memo": memo }) return self.finalizeOp(op, account, "active")
def test_Transfer(self): op = operations.Transfer(**{ "from": "foo", "to": "baar", "amount": "111.110 STEEM", "memo": "Fooo" }) 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 = ("f68585abf4dce7c80457010203666f6f046261617206b201000000" "000003535445454d000004466f6f6f00012025416c234dd5ff15d8" "b45486833443c128002bcafa57269cada3ad213ef88adb5831f63a" "58d8b81bbdd92d494da01eeb13ee1786d02ce075228b25d7132f8f" "3e") self.assertEqual(compare[:-130], tx_wire[:-130])
{ 'from': 'runburgundy', 'to': 'mstafford', 'amount': '0.003 SBD', 'memo': 'Test Transfer 3' } ] print(transfers) # now we can construct the transaction # we will set no_broadcast to True because # we don't want to really send funds, just testing. tb = TransactionBuilder() # lets serialize our transfers into a format Steem can understand operations = [operations.Transfer(**x) for x in transfers] print(operations) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operations) print(tb) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. # since all payments are made from `richguy`, # we just need to do this once tb.appendSigner('runburgundy', 'active') # sign the transaction tb.sign() print(tb)
return end2 - end1, end1 - start if __name__ == "__main__": steem_test = SteemTest() beem_test = BeemTest() steem_test.setup() beem_test.setup() steem_times = [] beem_times = [] loops = 50 for i in range(0, loops): print(i) opSteem = steemOperations.Transfer(**{ "from": "foo", "to": "baar", "amount": "111.110 STEEM", "memo": "Fooo" }) opBeem = operations.Transfer(**{ "from": "foo", "to": "baar", "amount": Amount("111.110 STEEM", steem_instance=Steem(offline=True)), "memo": "Fooo" }) t_s, t_v = steem_test.doit(ops=opSteem) steem_times.append([t_s, t_v]) t_s, t_v = beem_test.doit(ops=opBeem) beem_times.append([t_s, t_v])
print("IS TOO MUCH!") return True else: return False # end def while(count <= 10000): betTX = [] betTX.append({ 'from': accountname, 'to': 'epicdice', 'amount': (str(betAmount) + ' STEEM'), 'memo': (AboveOrBelow + ' ' + str(OverUnderNum)), }) tb = TransactionBuilder() ops = None ops = [operations.Transfer(**x) for x in betTX] tb.appendOps(ops) tb.appendSigner(accountname, "active") tb.sign() tb.broadcast() userAcct = Account(accountname) steemBalance = Amount(userAcct['balance']).amount print(" ") print("Balance: %s STEEM" % steemBalance) print ('bet # ' + str(count)) print((str(betAmount) + ' STEEM ') + ((AboveOrBelow + ' ' + str(OverUnderNum)))) if steemBalance <= stopLose: print("%s STEEM left, hit stopLose." % steemBalance) break elif steemBalance >= stopWin: print("%s STEEM left, hit stopWin." % steemBalance)
AboveOrBelow = 'Above' # can be 'Above' or 'Below' OverUnderNum = 6 #betAmount = 1 #AboveOrBelow = 'Below' # can be 'Above' or 'Below' #OverUnderNum = 95 ops = [ { 'from': accountname, 'to': 'epicdice', 'amount': str(betAmount) + ' STEEM', 'memo': str(AboveOrBelow) + ' ' + str(OverUnderNum) } ] operations = [operations.Transfer(**x) for x in ops] s = Steem(node = nodes, keys=[PK]) count = 1 #do not modify - is part of loop + display sleepAmt = 4 while(count <= 1001): tb = TransactionBuilder() tb.appendOps(operations) tb.appendSigner(accountname, "active") tb.sign() tb.broadcast() print ('bet # ' + str(count)) count = count + 1 time.sleep(sleepAmt)