First Attempt on BSN: Deploy a Sample Fabric Chaincode in BSN Testnet

Introduction

Quick Overview of BSN

Difference between using Fabric natively and Fabric adapted in BSN
BSN Connection Flow (Source: BSN User Manual v1.3.0 link)

Demonstration Arrangement

BSN Account

Setup

Chaincode

BSN PCN Gateway SDK

Demonstration Detail

Prepare Chaincode Package

cd fabric-samples/chaincode/
cp -r sacc testBSN
cd testBSN
zip -r testBSN.zip testBSN/

Upload and Deploy Chaincode Package

Successful deployment of chaincode in Testnet

Access Application / Invoking Chaincode Functions with Python SDK

from bsn_sdk_py.client.config import Config
from bsn_sdk_py.client.fabric_client import FabricClient
nodeApi = "http://119.8.103.189:4004"
user_code = "USER0003202009052048235246180"
app_code = "app003eaab3197d3f342fdb217563493efd3c8"
chaincode = "cc_8b6c2a8007904790a020accf8bbb19f7"
app_public_cert_path = "/home/ubuntu/testcert/gatewayCert/gateway_public_cert_secp256r1.pem"
user_private_cert_path = "/home/ubuntu/testcert/userAppCert/secp256r1/private_key.pem"
mspDir = "/home/ubuntu/testcert/fabricMsp"
httpcert = ""
c = Config(user_code, app_code, nodeApi, mspDir, httpcert, app_public_cert_path, user_private_cert_path)client = FabricClient()
client.set_config(c)
result = client.req_chain_code(chaincode,'set','',['name','Peter'])
result.get('body').get('ccRes')
Comparison: using peer command without BSN.
result = client.req_chain_code(chaincode,'get','',['name'])
result.get('body').get('ccRes')
Comparison: using peer command without BSN.
client.get_ledger_info().get('body').get('height')client.req_chain_code(chaincode,'set','',['name','John'])client.get_ledger_info().get('body').get('height')

Summary

Visit http://www.ledgertech.biz/kcarticles.html for all my works. Reach me on https://www.linkedin.com/in/ktam1/ or follow me @kctheservant in Twitter.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store