学习笔记4:steemmonsters的一些账户操作

in STEEM CN/中文10 months ago (edited)

在村长的帮助下,学习了很多关于steemmonsters的一些操作。

记录一下当个备忘:

首先是加载各种库和新建一个class。

from steem import Steem
from steem.blockchain import Blockchain
from api import Api

nodes = ['https://steemd.minnowsupportproject.org']


class Requests:

    def __init__(self,private_posting_key):
        self.s = Steem(nodes,keys=private_posting_key)
        self.b = Blockchain(steemd_instance=self.s)

获取赛季奖励:season是当前赛季号码

#获取赛季奖励
    def claim_season(self,name,season):

        json_data = {"type":"league_season","season":season,"app":"steemmonsters/0.7.6"}

        self.s.custom_json('sm_claim_reward', json_data, required_posting_auths=[name])

#换新任务,任务不满意的时候就换换

#换新任务
    def refresh_quest(self, name):

        json_data = {"type":"daily","app":"steemmonsters/0.7.7"}

        self.s.commit.custom_json('sm_refresh_quest',json_data, required_posting_auths=[name])

赠送卡片,有长度限制,大概一次40-50张左右差不多

 #发送一张卡片,card_id是要赠送的卡片id
    def send_card(self,name,toplayer,card_id):
        json_data = {"to": toplayer,"cards":[card_id]}
        self.s.custom_json('sm_gift_cards', json_data, required_posting_auths=[name])

游戏里的DEC操作相关

#游戏里提现DEC到steem-engines
    def transfer_withdraw(self,name,money_number):
        json_data = {"to":"steemmonsters","qty":money_number,"token":"DEC","type":"withdraw","app":"steemmonsters/0.7.7"}
        self.s.custom_json('sm_token_transfer', json_data, required_posting_auths=[name])

    # 游戏里提现DEC转账到别人
    def transfer_toplayer(self, name, money_number,toplayer):
        json_data = {"to": toplayer, "qty": money_number, "token": "DEC", "type": "withdraw",
                     "app": "steemmonsters/0.7.7"}
        self.s.custom_json('sm_token_transfer', json_data, required_posting_auths=[name])

steem-engines转账DEC给别人,里面的DEC改一改,也可以转别的币

#steem-engines转账DEC
    def transfer_se_trans(self,name,toplayer,money):
        contract_payload = {'symbol': 'DEC', 'to': toplayer, 'quantity': str(money), 'memo': ''}
        json_data = {'contractName': 'tokens', 'contractAction': 'transfer', 'contractPayload': contract_payload}
        tx=self.s.commit.custom_json('ssc-mainnet1', json_data, required_auths=[name])
        return tx

提现steemp变成steem

 #提现steemp
    def transfer_withdraw_steemp(self,name,money):
        json_data = {"contractName":"steempegged","contractAction":"withdraw","contractPayload":{"quantity":str(money)}}
        tx=self.s.commit.custom_json('ssc-mainnet1', json_data, required_auths=[name])
        return tx

卖掉卡片

卖卡的卡片格式是这样的:
sell_groud=[{"cards":["G4-171-A6T2NQ5IY8"],"currency":"USD","price":0.65,"fee_pct":500}]

长度有限制,大概20张差不多

# 卖卡
    def transfer_sell_card(self, name, sell_groud):
        json_data = sell_groud
        #sell_groud=[{"cards":["G4-171-A6T2NQ5IY8"],"currency":"USD","price":0.65,"fee_pct":500}]
        tx = self.s.commit.custom_json('sm_sell_cards', json_data, required_posting_auths=[name])
        return tx

记录一下,免得自己忘记了。

Sort:  

steem一直在默默地发展,居然还有steem monster游戏出来了。。。