Skip to main content

SDK for BSN(Blockchain Service Network)

Project description

BSN Python SDK

Author: 李大狗Leeduckgo

Org: 上海对外经贸大学·人工智能与变革管理学院·区块链技术与应用研究中心

bsn-python-sdk is a Python library for communicating with Blockchain Service Network, It is used for building blockchain Apps with BSN.

It provides:

  • 5 APIs ( create, update, query, delete, get_history ) abount default chainCode in BSN.

bsn-python-sdk 是一个用于和 BSN 区块链服务网络相联系的 Python 库,其被用于构建和 BSN 相关的 区块链 App。


  • 包含「增、减、查、改、查询历史记录」的默认链码包中的五个接口的调用。


Install and update using pip:

pip3 install bsn-sdk

A Simple Example

from bsn_sdk import Operator
# user_code, app_code, chain_code, url and cert_path
op = Operator("reddate", "CL1851016378620191011150518", "cc_base", "", "./certificate")

# save_data
res = op.save_data("leeduckgo5","test")
# res = {'success': True, 'payload': {'txId': 'c69af29cc00c68456b9e6fe9013f8e4f15ed6e09e3b2250ae3561b9a122ec509', 'context': None}}

# get_data
res = op.get_data("leeduckgo5")
# {'success': True, 'payload': {'txId': '92b61460a31d323d54121c25fced24cacc5102b309f310044ad6b36f42bf05a6', 'context': 'test'}}

# update_data
res = op.update_data("leeduckgo5", "testtest")
# {'success': True, 'payload': {'txId': 'abfe9ee4628efc07086fb81a5b37ef5126898f042868c3d9fade7a7d316ec613', 'context': 'SUCCESS'}}

# delete_data
res = op.delete_data("leeduckgo5")
# {'success': True, 'payload': {'txId': '1b0f298004c9a617ed84dfd4bb989ed03f46e6676668cccfb3bd23117fcd6356', 'context': 'SUCCESS'}}

# get_history
res = op.get_history("leeduckgo5")
{'success': True, 'payload': {'txId': '3ec3174424070b04311af22e0694bba6e099821090cb761a7fae60ce89ef29d4', 'context': [{'txId': 'c69af29cc00c68456b9e6fe9013f8e4f15ed6e09e3b2250ae3561b9a122ec509', 'dataInfo': '{"BaseKey":"leeduckgo5","BaseInfo":"test"}', 'txTime': '2020-01-22 13:18:37', 'isDelete': False}, {'txId': 'abfe9ee4628efc07086fb81a5b37ef5126898f042868c3d9fade7a7d316ec613', 'dataInfo': '{"BaseKey":"leeduckgo5","BaseInfo":"testtest"}', 'txTime': '2020-01-22 13:20:03', 'isDelete': False}, {'txId': '1b0f298004c9a617ed84dfd4bb989ed03f46e6676668cccfb3bd23117fcd6356', 'dataInfo': '', 'txTime': '2020-01-22 13:22:21', 'isDelete': True}]}}


It will supported more chainCode next( ´Д`)y━・.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bsn-sdk-0.1.3.tar.gz (5.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page