Bitshares|Bitshares RPC Example

Install python-graphenelib

pip3 install graphenelib

For more information, refer to github
RPC to node example
from grapheneapi import grapheneapi import jsonif __name__ == '__main__': graphene = grapheneapi.GrapheneAPI("node ip", port_number)tx = graphene.get_chain_properties() print(json.dumps(tx, indent=4))accounts = ["1.2.0", "1.2.1"] tx = graphene.get_accounts(accounts) print(json.dumps(tx, indent=4))

RPC to wallet example 【Bitshares|Bitshares RPC Example】To connect a wallet, start the cli_wallet with " -r 127.0.0.1:8093 "
from grapheneapi import grapheneapi import jsonif __name__ == '__main__': graphene = grapheneapi.GrapheneAPI("localhost", 8093)tx = graphene.list_account_balances("nathan") print(json.dumps(tx, indent=4))tx = graphene.transfer("nathan", "alpha", "10", "BTS", "good job", True) print(json.dumps(tx, indent=4))

RPC to create asset
from grapheneapi import grapheneapi import json import randomperm = {} perm["charge_market_fee"] = 0x01 perm["white_list"] = 0x02 perm["override_authority"] = 0x04 perm["transfer_restricted"] = 0x08 perm["disable_force_settle"] = 0x10 perm["global_settle"] = 0x20 perm["disable_confidential"] = 0x40 perm["witness_fed_asset"] = 0x80 perm["committee_fed_asset"] = 0x100if __name__ == '__main__': graphene = grapheneapi.GrapheneAPI("127.0.0.1", 8093)permissions = {"charge_market_fee" : True, "white_list" : True, "override_authority" : True, "transfer_restricted" : True, "disable_force_settle" : True, "global_settle" : True, "disable_confidential" : True, "witness_fed_asset" : True, "committee_fed_asset" : True, } flags= {"charge_market_fee" : False, "white_list" : False, "override_authority" : False, "transfer_restricted" : False, "disable_force_settle" : False, "global_settle" : False, "disable_confidential" : False, "witness_fed_asset" : False, "committee_fed_asset" : False, } permissions_int = 0 for p in permissions : if permissions[p]: permissions_int += perm[p] flags_int = 0 for p in permissions : if flags[p]: flags_int += perm[p] options = {"max_supply" : 10000, "market_fee_percent" : 0, "max_market_fee" : 0, "issuer_permissions" : permissions_int, "flags" : flags_int, "core_exchange_rate" : { "base": { "amount": 10, "asset_id": "1.3.0"}, "quote": { "amount": 10, "asset_id": "1.3.1"}}, "whitelist_authorities" : [], "blacklist_authorities" : [], "whitelist_markets" : [], "blacklist_markets" : [], "description" : "My fancy description" }asset_options = { "feed_lifetime_sec": 86400, "minimum_feeds": 1, "force_settlement_delay_sec": 86400, "force_settlement_offset_percent": 0, "maximum_force_settlement_volume": 2000, "short_backing_asset": "1.3.0", "extensions": [] } for x in range(1, 3): symbol = "NEST%dC" % x print(symbol) tx = graphene.create_asset("nathan", symbol, 5, options, asset_options, True) print(json.dumps(tx, indent=4))

    推荐阅读