BSN User Manual
BSN User Manual
BSN User Manual
Version 1.8.1
BSN Foundation
Blockchain-based Service Network User Manual
CONTENTS
1 BSN Introduction ....................................................................................................................... 1
1.1 Brief Introduction ............................................................................................................................... 1
1.2 BSN Services ...................................................................................................................................... 2
1.2.1 Permissioned Services........................................................................................................... 2
1.2.2 Permissionless Services ........................................................................................................ 2
1.2.3 Interchain Services ................................................................................................................ 3
1.3 Terminologies ..................................................................................................................................... 3
2 Release Notes ............................................................................................................................ 5
3 Quick Start ................................................................................................................................ 9
3.1 Permissioned Blockchain .................................................................................................................... 9
3.2 Permissionless Blockchain ............................................................................................................... 10
3.3 Documentation .................................................................................................................................. 11
4 Registration and Activation .................................................................................................... 12
4.1 Registration ....................................................................................................................................... 12
4.2 Login ................................................................................................................................................. 14
4.3 Forgot Password ............................................................................................................................... 15
5 Permissioned Services ............................................................................................................ 17
5.1 Overview........................................................................................................................................... 17
5.2 BSN Keys and Certificates Mechanism ............................................................................................ 18
5.2.1 BSN Keys and Certificates Mechanism .............................................................................. 18
5.2.2 Locally generate the DApp access key pair ........................................................................ 19
5.3 DApp Services Publication and Participation ................................................................................... 20
5.3.1 Overview ............................................................................................................................. 20
5.3.2 DApp Services Publication ................................................................................................. 20
5.3.3 DApp Services Management .............................................................................................. 27
5.3.4 DApp Services Participation ............................................................................................... 30
5.4 Off-BSN System Access Guide ........................................................................................................ 36
5.4.1 Overview ............................................................................................................................. 36
5.4.2 BSN Smart Contract Package Requirements ...................................................................... 40
5.4.3 PCN Gateway Fabric API ................................................................................................... 46
5.4.4 PCN Gateway FISCO API .................................................................................................. 72
5.5 Development SDK and Examples .................................................................................................... 96
5.5.1 BSN Gateway SDK Example ............................................................................................. 96
2
Blockchain-based Service Network User Manual
3
Blockchain-based Service Network User Manual
4
Blockchain-based Service Network User Manual
5
Blockchain-based Service Network User Manual
Preface
Blockchain-based Service Network (BSN or Service network) is a worldwide
infrastructure network that provides a one-stop-shop solution for blockchain and
distributed ledger technology (DLT) applications (DApp). BSN is a complex system
that involves programming, software development, resource and environment
configurations, application deployment, gateway APIs, local SDK, key certificates, etc.
To facilitate utilization, BSN International (www.bsnbase.io) has prepared this
document for developers and users to learn how to use BSN. We hope that BSN will
become the first choice for developers to develop and run their DApps.
Permissioned services are divided into two parts. The first part demonstrates how
developers can deploy smart contracts to the selected public city nodes through the BSN
portal; the second part describes how developers can connect their off-BSN systems to
the corresponding smart contracts through the public city node gateway and conduct
data transaction processing.
Permissionless services determine how developers can choose the appropriate public
city nodes, plans, and public chain frameworks, to deploy and publish their DApps.
Please feel free to contact us if there are any further questions. Our contact information
can be found in Chapter 14. Contact Us. We strongly recommend users access the
Online Documentation section to explore BSN technical details further.
1
Blockchain-based Service Network User Manual
1 BSN Introduction
With BSN, there are three types of participants: cloud service providers, blockchain
framework providers, and portal operators.
Cloud service providers, through the installation of free BSN public city node software,
can make their cloud service resources (computing power, storage, and bandwidth)
accessible and sell through BSN to end-users.
Blockchain framework providers align with the BSN’s framework adaptation standards
and deploy them on BSN so developers can use it to develop and deploy applications.
The Permissionless service only applies to the BSN international portal and
international public city nodes.
Portal operators can easily and quickly build a Blockchain as a Service (BaaS) platform
on their existing websites using BSN APIs. This allows them to provide BSN
capabilities to their end users without users leaving their websites.
BSN is an open network that any cloud service provider, framework provider, or portal
operator, that complies with BSN requirements and standards is free to use and stop
using the service network at any time.
Similar to the Internet, most users of BSN are developers and technology companies.
They can use any BSN portal to purchase cloud resources that charge based on
transactions per second (TPS), storage quantity, and bandwidth from any public city
node around the world. They select any pre-adapted framework to conveniently develop,
deploy, and manage permissioned blockchain applications at a very low cost.
Blockchain developers only need to deploy the application to one or more public city
nodes on BSN so participants can connect to the application at no cost through any
public city node gateway. All deployed applications share server resources in every
public city node. For high-frequency applications, public city nodes can intelligently
allocate a dedicated peer node with high processing capacity. For low-frequency
applications, they share the same peer node. This resource-sharing mechanism allows
BSN to reduce the resource cost to one-twentieth of the cost of traditional blockchain
cloud services.
BSN is a blockchain infrastructure network. Just as households do not need to dig their
own wells, but instead, enjoy the water supply services provided by public water plants
in cities, BSN blockchain application publishers and participants do not need to buy
physical servers or cloud resources to build their blockchain operating environment.
1
Blockchain-based Service Network User Manual
They use the public services provided by BSN and rent shared resources as needed, thus
greatly reducing their costs. According to recent research, it takes about 20,000 USD
per year for developers to build and deploy a traditional permissioned blockchain LAN-
type environment. However, with BSN, the minimum cost to run such an application is
as low as one dollar a day. Cost is a huge factor and will encourage a large number of
small, medium, and micro enterprises and even individuals (including students) to
innovate and start businesses through BSN. This will undoubtedly promote rapid
development and popularization of blockchain technology. In general, the development
from the closed architecture of the traditional blockchain to the resource-sharing
architecture of BSN completely mimics the development process of the Internet, which
gathered numerous isolated LANs in the early days to the global connectivity facilities
we have today. We hope to make BSN the blockchain Internet.
The pricing strategy for the Permissioned service is based on three resource elements
of each peer node of the published application. The three elements are TPS, storage,
and data traffic. Among them, TPS and storage in the BSN portal are pre-paid, while
data traffic will be charged based on actual usage. This pricing strategy is designed to
minimize resource costs and provide users with the best services. Based on the data
provided by the BSN portal, if a user deploys a three-peer Fabric DApp, and each peer
node supports 10TPS and 10GB storage capacity, the monthly fee is only 20 USD.
The pricing strategy of BSN dedicated node services is based on the host configuration,
hard disk, and data usage of the cloud platform selected for the service, where the host
configuration and hard disk are prepaid, and the data usage fee is postpaid according to
the actual amount incurred; the pricing strategy of interchain services is postpaid
according to the actual number of cross-chain calls occurred; the permissioned services,
oracle services and interchain services provided by the BSN Testnet services are all free
of charge.
(www.bsnbase.io) and international public city nodes. Compared with the complexity
of the Permissioned service, Permissionless service has the virtue of simplicity. The
Permissionless service mainly provides developers who develop public chain DApps,
with unified access service covering numerous public chain nodes. Developers may
choose different plans on the BSN portal, and can simultaneously deploy DApps and
process transactions on all BSN adapted public chain nodes through the selected public
city nodes.
We offer a free plan and different premium plans. The free plan includes up to 2,000
requests per day. There are 3 types of premium plans, priced at $20, $100, and $500 per
month. The premium plans include up to 20,000 requests, 125,000 requests, and
750,000 requests, respectively, per day. All requests can be assigned to any public chain
freely.
Permissionless services only provide shared nodes and access environments and do not
involve any business of the public chain itself. The gas fees incurred in publishing and
running DApps on any public chain shall be borne by the developers themselves and
have nothing to do with BSN.
A demo version of ICH is also live on the BSN Testnet, integrating two interchain
solutions based on the relay chain mechanism: (1) Poly Enterprise developed by
Onchain and (2) IRITA developed by Bianjie. We welcome all developers to try out
and provide feedback and suggestions to us and we will continue to improve the
interchain functionality.
1.3 Terminologies
⚫ Public city node (PCN): This is the core element of BSN but the “node” part
doesn’t refer to the blockchain nodes and BSN isn’t a blockchain. With BSN, each
PCN is a virtual data center used to allocate a portion of resources from the cloud
3
Blockchain-based Service Network User Manual
4
Blockchain-based Service Network User Manual
2 Release Notes
Release date Version Notes
• Optimized DID Services functions and interfaces;
2022/04/24 1.8.1
• Added Unsubscribe function in Permissioned Services.
• Iterative optimization and technical optimization of the BSN
international website (www.bsnbase.io) to enhance user
experience;
• Added the cross-chain function of Hyperledger Fabric V2.3.2
framework by Poly Enterprise and IRITA in the Interchain
Communications Hub;
2022/01/23 1.8.0
• Integrated Hyperledger Fabric V2.3.2 to the BSN Testnet;
• Upgraded the version of Hyperledger Fabric from 2.2.0 to
2.3.2 in the Dedicated Node Services;
• Integrated Klaytn public chain and provide external services
on the international website and international nodes;
• Fixed bugs and enhanced the stability of the system.
• Iterative optimization and technical optimization of the BSN
international website (www.bsnbase.io) to enhance user
experience;
• Added Hyperledger Fabric V2.3.2 framework to Permissioned
Services;
• Added Configuration Upgrade function in the Dedicated Node
Services;
2021/10/31 1.7.0 • Upgraded IRITA in the Testnet to support Ethereum Ropsten
network and Chainlink oracle services;
• Launched BSN DID Services to support credential issuance,
authentication and authorized access management in a unified
identity management system;
• Integrated Cypherium public chain and provide external
services on the international website and international nodes;
• Fixed bugs and enhanced the stability of the system.
• Iterative optimization and technical optimization of the BSN
international website (www.bsnbase.io) to enhance user
experience.
• Launched BSN dedicated node services based on Hyperledger
Fabric V2.2.0 and Hyperledger Besu V21.1.2 frameworks.
2021/07/31 1.6.0 • Optimized and improved Interchain Communications Hub's
protocols and service stability.
• Updated the interface of the BSN Empowerment Platform to
provide the DApp service management APIs of Open
Permissioned Blockchains and BSN Testnet to BSN portals.
• Fixed some bugs and enhanced the stability of the system.
• Launched IDE Services, supports frameworks including
2021/05/31 1.5.1 Hyperledger Fabric, FISCO BCOS, Ethereum, Nervos and
Algorand.
5
Blockchain-based Service Network User Manual
6
Blockchain-based Service Network User Manual
manual.
8
Blockchain-based Service Network User Manual
3 Quick Start
3.1 Permissioned Blockchain
9
Blockchain-based Service Network User Manual
Permissioned DApp Service publishers can create DApp services in the BSN portal. To
create the service, it is necessary to upload the smart contract/chaincode package, define
the service functions and roles, select the public city nodes and select the participant
certificate mode (including Key Trust mode and Uploaded Public Key mode). After
that, publishers pay the bills and submit the service deployment request to the network
operator for approval and publishing.
After the successful publication of the service, publishers can participate in their service
or invite other users to participate in the service. To participate in the service,
participants should select designated roles and the access public city node, then generate
the certificates according to the certificate mode set by publishers. Participation will be
successful after being approved by service publishers.
Once successfully participating in the service, participants can download the certificate,
and use the certificate and service access configuration parameters to access the
chaincodes/smart contracts through the gateway API.
10
Blockchain-based Service Network User Manual
Permissionless services allow visitors to select public city nodes and plans to participate
in a service. There are 2 types of plans, the free plan, and premium plans. Visitors can
choose plans according to their business requirements. To connect to the public chain
nodes, users can create projects to obtain project IDs, project keys, and access addresses
to access the public chain services.
3.3 Documentation
The direct users of the BSN portal are developers. As the environment and tools of the
blockchain application's development, deployment, and operation, BSN is relatively
complex in its overall operation. We strongly recommend that all developers start by
examining the documentation and examples so that they will be able to master the use
of BSN within a day or two.
For your convenience, all examples we've provided are available on Github. We hope
that developers with serious interest can help us optimize and enrich the examples so
that other developers are able to adapt and learn about blockchain development.
Developers who share their samples, will receive small gifts and be invited to BSN's
internal technical seminar.
For links to all documents and examples, please visit Chapter 13. Online
Documentation.
11
Blockchain-based Service Network User Manual
4.1 Registration
1. Click here to access the website at www.bsnbase.io.
2. With the blockchain-based service network, you can access the system either as an
Individual or a Corporate entity.
3. To register as an Individual, enter or select the following:
• Username – Enter a preferred username
• Nationality – Click the dropdown to select your country from the list of
countries
• Name – Enter your real name, different from the username
• Mobile Number (Optional) – Enter your mobile number
• Email address – Enter an email address you have access to
• Brief description of your programming experience (Optional) – If you have
some experience in programming, we would love to hear about it
• Check the I have read and agree to Terms of User and Privacy Policy box
• Click Confirm to finish the registration.
12
Blockchain-based Service Network User Manual
13
Blockchain-based Service Network User Manual
6. You will receive an email from BSN requesting that you confirm your registration.
7. Click on the link in the email to confirm your registration and enter your Password
and Password Confirmation.
8. Click Confirm when done to return you to the login page.
4.2 Login
After you have successfully registered your account on BSN, you can login by
following these steps:
14
Blockchain-based Service Network User Manual
1. On the Login page, click the Forgot Password to open the forgot password page.
2. On the page, enter the correct account or email.
3. In the verification code, enter the displayed code. If you wish to generate another
code, click on the code to generate another.
15
Blockchain-based Service Network User Manual
6. Enter the code that was received in your mailbox and click Next.
7. On the reset login password page, enter your New password and Confirm
password.
8. Click Confirm to change your password.
16
Blockchain-based Service Network User Manual
5 Permissioned Services
5.1 Overview
The Permissioned service is one of the core services provided by BSN. Its goal is to
make it easy for developers to publish decentralized applications (DApps) based on the
framework of the permissioned blockchain on their selected public city nodes.
Compared with the permissionless blockchain DApp, the permissioned blockchain
DApp is more flexible in terms of architecture design, operation efficiency, and smart
contract programming. It also has a larger space for innovation. However, from the
perspective of development, because the developers need to build their underlying
environments, and the environment for the public chain is readily available, the
development, operation and maintenance of the permissioned chain DApp are relatively
difficult. The developer's off-BSN system can access to DApp for data processing
through the BSN public city node gateway.
Although BSN has greatly reduced the difficulty of permissioned blockchain DApp
development, developers still need to have an in-depth understanding of the following
three aspects which will be explained in detail in the following chapters.
17
Blockchain-based Service Network User Manual
developers need to upload or download keys to facilitate the access from off-BSN
system.
3. Off-BSN system access: This part contains a detailed description of the access
parameter configuration, SDK usage, and the description of public city node
gateway APIs to which the off-BSN systems connect. The API section includes all
APIs of the currently permissioned blockchain frameworks that BSN has adapted.
1. DApp Access Key Pair based on Key Trust Mode: DApp access key pair is used
to generate the certificate to access the PCN gateway. If the DApp is on Key Trust
Mode, the key pair can be generated on the BSN portal, and the private key can be
downloaded. Please refer to the BSN Help Manual’s service participation section.
2. User Transaction Key Pair based on Key Trust Mode: User transaction key pair is
used to verify the requests and transactions sent to the DApp. If the DApp is on
Key Trust mode, the key pair can be generated via the PCN gateway APIs by
executing requests from the off-BSN systems. If the off-BSN systems have sub-
users, it can even generate different key pairs for different sub-users. Refer to the
API sections in this document for Hyperledger Fabric and FISCO BCOS
frameworks to see how to generate the key pairs and use them to verify the
transactions.
3. DApp Access Key Pair based on Public Key Upload Mode: In this mode, the DApp
access key pair is generated and stored locally. The participant must upload the
public key to BSN via the BSN portal to generate the access certificate to the PCN
gateway. Please refer to section 5.2.2 below to see how to generate the key pair
locally. Please refer to the “Public Key Upload” section of this document to learn
how to upload the public key to BSN via the portal.
4. User Transaction Key Pair based on Public Key Upload Mode: In this mode, the
18
Blockchain-based Service Network User Manual
user transaction key pair is also generated and stored locally. Instead of using the
BSN portal, the user transaction public key (one of the pair) is sent and registered
on BSN via the PCN gateway certificate registration API. If the off-BSN systems
have sub-users, they can also upload different public keys to generate different
transaction certificates for different sub-users by using the API. Please refer to
section 5.2.2 or the instructions inside the gateway SDK package about generating
the key pair locally. Refer to the API sections in this document for registering the
certificate via gateway APIs.
Please click the link to download the PCN Gateway SDK Package:
https://github.com/BSNDA/PCNGateway-Go-SDK
https://github.com/BSNDA/PCNGateway-Java-SDK
https://github.com/BSNDA/PCNGateway-PY-SDK
https://github.com/BSNDA/PCNGateway-CSharp-SDK
Currently, both permissioned frameworks Hyperledger Fabric and FISCO BCOS
DApps support both Key Trust Mode and Public Key Upload Mode.
19
Blockchain-based Service Network User Manual
5. Input the command - "dgst -sha256 -sign key.pem -out signature.bin data.txt" to
sign the data.txt file with the private key in the key.pem file to generate the
signature file: signature.bin.
OpenSSL> dgst -sha256 -sign key.pem -out signature.bin data.txt
6. Input the command - "dgst -verify pub.pem -sha256 -signature signature.bin
data.txt". Use the public key in the pub.pem file to sign and verify the data.txt and
signature.bin files.
OpenSSL> dgst -verify pub.pem -sha256 -signature signature.bin data.txt
Verified OK
7. If "Verified OK" is displayed, input the command - "base64 -in signature.bin -out
signature64.txt" to convert the signature file signature.bin to base64 encoded
signature64.txt.
OpenSSL> base64 -in signature.bin -out signature64.txt
8. Input the command - "pkcs8 -topk8 -inform PEM -in key.pem -outform PEM -
nocrypt -out keypkcs8.pem" to convert the private key in the key.pem file to pkcs8
format.
OpenSSL> pkcs8 -topk8 -inform PEM -in key.pem -outform PEM -nocrypt -out
keypkcs8.pem
9. Save the keypkcs8.pem file locally and copy all the contents of pub.pem, data.txt,
and signature64.txt to the public key, test data, and signature data text boxes
respectively on the Public Key Upload Mode page to verify the public key and
submit it to BSN.
1. In the BSN menu, click the Permissioned Services dropdown, in the list, click
Published Services to open the Published Services page.
20
Blockchain-based Service Network User Manual
• Service Logo – Click on the icon to locate the image on your PC. Note that
the image must be in png/jpg/jpeg format and should be exactly 160 x 160
pixels.
Enter a Name, and choose a Type for the document. Click Confirm to add the
21
Blockchain-based Service Network User Manual
document.
5. In the Contact Information section, the login details of the user are automatically
populated, including the Contacts and Email. If necessary, you can add a
telephone number.
1. To Add Chaincode Package, click on the button to display the Add Chaincode
Package where you enter or select the following:
• Chaincode Name – Enter a name for the chaincode
• Version – Enter the chaincode version
• Chaincode Language – Select from one the languages (Java, Golang or
NodeJS)
• Initparam – enter the initialization parameters and if multiple, separate it with
commas
• Chaincode Package – Click on the icon to select the package file from the
PC. Package files are to be in the .zip file format and the file name should only
contain letters and numbers or underscores
22
Blockchain-based Service Network User Manual
2. To Use Preset Chaincode Package, click on the button to display the Select preset
chaincode package option. In the list of packages, select one of the listed packages
and click Confirm to add it.
23
Blockchain-based Service Network User Manual
2. If you wish to add more functions, click the Add Functions button to display the
dialog box. In it, enter or select the following:
• Function Name – Enter a name for the function
• Chaincode Name – Select from the list of chain codes
• Chaincode FUNC type – Choose from invoke, query or event
• Chaincode FUNC – Enter a description of the function
• Superior Functions – Select a function from the list of functions in the system
24
Blockchain-based Service Network User Manual
1. In the Select the City Nodes to deploy the service section, click Add City Nodes.
25
Blockchain-based Service Network User Manual
4. In the list of carriers, select more than one carrier for redundancy purposes. When
done, click Confirm.
The city nodes that have enough resources according to the TPS and storage
configuration are displayed alongside their costs. The resource costs are different for
each public city node.
1. To use the certificate mode, in the Certificate Mode section, click either Key
Trust Mode or Public Key Upload Mode.
26
Blockchain-based Service Network User Manual
Once the payment is successfully made, you will receive an email in your mailbox
informing you that your BSN service has been submitted successfully and will be
reviewed. You will be informed via email when the reviewed has finished.
Once the service has been approved, the service will be seen in the Published Services
section.
1. In the BSN menu, click the Permissioned Services dropdown and click Published
Services to display the list of published services.
2. In the Action column, select the Invite Participants link to display the details to
send to participants who intend to join the service.
Click Copy to copy the link details. This can be emailed to the participants who login
with their BSN credentials to join or register with BSN first to use the service.
27
Blockchain-based Service Network User Manual
1. In the list of published services, locate the service to be edited. In the Action
column of the service, select Edit Basic Information to display the editing page.
2. Add, edit or remove the basic detail of the service and click Save to store changes.
If no changes were made click Back to return to the Published Services page.
5.3.3.3 Service Upgrade
After a service has been published, the publisher can use the Service Upgrade option
to update the smart contracts and other functions. It will be reviewed again before it can
be used. To edit the Service Upgrade, follow these steps:
1. In the list of published services, locate the service to be edited. In the Action
column of the service, choose Service Upgrade.
2. In the Basic Information page, change the Version Number, which is mandatory
and/or any other details in the Basic Information page. Click Next to upload the
new smart contracts and set functions and roles as described before.
When done, click Confirm
1. Go to Published Services and select the enabled service on the list. Click
configuration upgrade to enter the configuration upgrade list page as below:
28
Blockchain-based Service Network User Manual
2. Click Add to create a configuration upgrade application form, and then click Add
city nodes to add new city nodes:
5.3.3.5 Details
The View option allows the publisher to view all the details of the published service
including Basic Information, Chaincode and Deployment, Roles, Review Records,
Operating Status, Comments/Inquiries, and Historical Version. To view these
options, follow these steps:
1. In the list of published services, locate the service to be edited. In the Action
29
Blockchain-based Service Network User Manual
column of the service, click Details to display the view page tabs.
2. In the Basic Information tab, you can see all the details of the service that has
been deployed including the Service Name, Industry, Version, Framework,
Service Logo, Service Introduction, Service Description, Documents, and
Contact Information.
3. In the Chaincode and Deployment tab, the information that can be viewed
includes the Chaincode Package, Service Functions, and City Nodes.
4. In the Roles tab, the roles and their related functions are listed. To View a role,
click on the view link for that role name.
5. In the Review Records tab, you will see all the requested approval and their status
as well as time logs.
6. The Operating Status tab shows more information about the published service
than any other tab. It shows the parameters of City Nodes, number of transactions,
Peer Information, Chaincodes, Blocks, and Logs of how the activities took place.
7. The Comments/Inquiries tab shows the comments made on the published service
that can be viewed by the publisher.
8. The Historical Version tab shows the history of the service including the Service
Name, Version, Industry, Service Introduction, and Action.
5.3.3.6 Service Unsubscribe
Users can unsubscribe published services. Click Unsubscribe in the published service
list.
For users whose service resources are paid monthly, no refund will be generated when
they unsubscribe; for users whose service resources are paid annually, refunds will be
made at the point of time from the next month to the end of the billing cycle, and the
refundable month will be cancelled when the refund is made, and the refund will be
tallied according to the actual remaining months.
1. Click the link that was shared. This will take you to the service information page.
2. In the service header, click Apply for the Service.
2. In the Public City nodes, click Add city nodes to display the Public City Nodes
the DApp is deployed on. You can select more than one node. The selected nodes’
gateways are where the off-BSN systems connect to. Please select the public city
node that is closest to you.
31
Blockchain-based Service Network User Manual
Key Trust Mode: Participants can select existing certificates on the city node or apply
for a new certificate.
Public Key Upload Mode: Participants should upload the public key, test data and
signature data. The generation of public and private keys can be viewed by clicking
Read Instruction.
32
Blockchain-based Service Network User Manual
2. For the participant to be reviewed, click the Review link in the Action column to
view the participant details. In the Review Result section select either Approved
or Not Approved and write a comment in the Comment box to give details.
33
Blockchain-based Service Network User Manual
4. If the participant is approved, a message will prompt showing that the service
participation approval was successful.
5. After the approval has been given, the participant can view the service from their
Participated Services page as well as add more city nodes.
5.3.4.6 Download and renew a certificate
The BSN development team intends to build BSN into a most secure blockchain
infrastructure network. The certificate and key mechanisms of BSN are complex. There
are two kinds of key pairs used in generating certificates: DApp Access Key Pair and
User Transaction Key Pair. For each, there are two modes, the Key Trust Mode and the
Public Key Upload Mode. To work with certificates, follow these steps:
1. In the My Certificates menu, click Key Trust Mode. The certificate page will be
displayed.
2. To download the certificate, click the icon. You will be required to enter the
certificate password.
34
Blockchain-based Service Network User Manual
3. To update the certificate, click the Certificate update link. You will be requested
to set a password for the certificate and confirm the password.
1. In the My Certificates menu, click Public Key Upload Mode. The certificate page
will be displayed.
2. To update the certificate, the public key, test data and signature data need to be re-
uploaded, and the update can only be completed after the test passes.
35
Blockchain-based Service Network User Manual
3. The user only needs to upload the public key in the Public Key Upload Mode. The
private key is kept locally by the user, so there is no need to download the certificate.
5.3.4.7 Configuration parameters for service access
To view and download the configuration parameters, follow these steps:
3. Click the dropdown beside the configuration parameters for service access to
view its configuration.
BSN aims to lower the cost of developing and deploying DApps by providing public
blockchain resources and environment to developers, just like the internet. It can further
reduce the costs associated with the development, deployment, operations, maintenance,
and regulation of DApps and, thereby, accelerate the development and universal
adaptation of blockchain and DLT technologies.
36
Blockchain-based Service Network User Manual
A complete DApp system based on BSN generally consists of two parts: the on-BSN
DApp smart contracts and the off-BSN systems. The off-BSN systems use the BSN
Public City Note (PCN) gateways to invoke the DApp smart contracts deployed on the
PCN to carry out on-chain operations such as executing transactions, writing data chain,
data queries, etc. The DApp service publishers and participants can deploy their off-
BSN systems on any cloud services they choose and then connect to the BSN PCN
gateways through the internet access DApp smart contracts and data.
Off-BSN System
PCN Gateway
Transaction Endorsement
Smart Contract/Chaincode
Events
Ledger
Peer Node
The BSN DApp service publishers and participants should have their off-BSN systems
so that they can access the DApp smart contracts to execute transaction and query data
via the PCN gateway APIs. The following are the charts to show the connecting flow
and transaction sequences.
37
Blockchain-based Service Network User Manual
38
Blockchain-based Service Network User Manual
Visit
Return verfication
result
Sccessful
Return chaincode
transaction result
Return Chaincode
Transaction Result
Return Results
39
Blockchain-based Service Network User Manual
⚫ Init: This function is called during the chaincode instantiation and its purpose is to prepare
the ledger for future requests. This function must be implemented in all chaincodes.
⚫ Invoke: The Invoke function is called for all future requests from the off-BSN systems
towards the DApps. Here all DApp custom functions or what the DApps can do (for
example, to read data from the ledger, to write data in the ledger, to update data, to delete
data) are defined. Simply put, Invoke can be understood as an entry point to the chaincode
functions. The Invoke function also must be implemented in all chaincodes.
⚫ Query: The Query function provides a method of querying ledger data. This function can
only be used for query purposes and does not offer any operations of ledger data. The Query
function is not required to be implemented in all chaincodes.
Note: Fabric 1.4 chaincode package cannot be directly used in Fabric 2.3.2, you need to modify
the contract according to the latest chaincode dependencies with the corresponding language.
To realize the automatic deployment of DApp services and to improve deployment efficiency,
the following Fabric chaincode packaging requirements have been issued with different
programming languages.
1. Golang
The main function must be at the same or higher level as all chaincodes in the project. The
zipping path must be the same level folder where the main function is located, and the main
function path is the src-based path.
├─main.go
├─ChainCode/
├─models/
└─utils/
The package should be zipped under BsnBaseCC/ (package name is not required), and the main
function path (reference path) is BsnBaseCC.
40
Blockchain-based Service Network User Manual
github.com
└─BSNDA
└─FabricBaseChaincode
└─chaincode
└─go
└─bsnBaseCC
└─main.go
└─ChainCode/
└─models/
└─utils/
Description: main.go: the entry; ChainCode: chaincode; models: entities; utils: utilities.
Note: Below is the structure of the Fabric 2.3.2 preset chaincode package
chaincode-demo
└─main.go
└─chaincode/
└─vendor/
└─go.sum
└─go.mod
2. Java
gradle or maven-built projects, the projects must contain build.gradle or pom.xml files.
BsnBaseCC
└─build.gradle
41
Blockchain-based Service Network User Manual
└─src
└─main
└─java
└─com.example.javacc
└─javacc.java
Package must be zipped under BsnBaseCC/, and there is no requirement for the name of .zip
package.
Note: src/main/java: project directory; com.example.javacc: package name; javacc.java:
chaincode information
3. Node.Js
package.json file must be built into the project’s root directory. Package needs to be zipped
under the directory of BsnBaseCC/. There is no requirement of the name of .zip package.
BsnBaseCC
└─marbles_chaincode.js
└─package.json
Note: when publishing DApp services in the BSN portal, chaincode packages should be created
in the project’s root directory using .zip format.
Fabric 2.3.2:
https://github.com/BSNDA/FabricBaseChaincode/tree/master/chaincode/go/bsnBaseChainco
de
DApp publishers can also select the preset chaincode package directly from the DApp
publishing page on the BSN portal.
42
Blockchain-based Service Network User Manual
Of which, the baseKey cannot be a blank string and the baseValue can be any type of data.
If the baseKey already exists, then directly return that it already exists and cannot be added;
if it does not exist, then add data.
Of which, the baseKey cannot be a blank string and the baseValue can be any type of data.
If the baseKey does not exist, then it cannot be updated; if it already exists, then update
the data.
Example: "str"
Of which, the baseKey value cannot be blank and must exist, else it cannot be deleted.
Example: "str"
Of which, the baseKey value cannot be blank and must exist, else it cannot be retrieved.
43
Blockchain-based Service Network User Manual
Example: "str"
Of which, the baseKey value cannot be blank. Response results: transaction Id (txId),
transaction time (txTime), whether to delete (isDelete) and transaction information (dataInfo).
We welcome developers to share their custom chaincodes as preset chaincode packages for the
BSN and work with us to expand the blockchain application support capabilities of the BSN.
44
Blockchain-based Service Network User Manual
about FISCO smart contract programming and further extend the functions, if needed. The
stored data types supported by this smart contract include int256(int), address, and string, of
which string cannot exceed 16MB. To ensure on-chain performance, there is no analysis of
duplicate base_id and base_key. This should be handled by the off-BSN system. It is
recommended that each base_id has only one corresponding base_key and base_value.
45
Blockchain-based Service Network User Manual
Of which, the base_id cannot be blank and must exist, otherwise, it is not possible to select the
corresponding data.
46
Blockchain-based Service Network User Manual
Parameters:
{"header":{"userCode":"user01","appCode":"app01"},"mac":"","body":{“userId”:”abc”,”list
”:[“abc”,”xyz”]}}
Result: user01app01abcabcxyz
5.4.3.2 Keys and Certificate Modes
1. Key Trust Mode
As described in chapter 5, DApp participants require two sets of key pairs to access the DApp:
DApp access key pair and user transaction key pair. With key trust mode, the pairs are
generated and hosted by BSN. The participants only need to download the private key (DApp
access key) from the BSN portal.
⚫ DApp Access Key Pair: After the participant has successfully joined the DApp, BSN will
generate one key pair (private and public keys) that corresponds to the DApp’s framework
algorithms under the Key Trust Mode. The participant can download the private key from
the “My Certificates” section of the BSN global portal and use it to sign the request message
sent to the PCN gateway. The gateway will use the hosted public key from the generated
key pair to validate the signature.
⚫ User Transaction Key Pair: This is the identity of a participant used to invoke the
chaincodes. Under the Key Trust Mode, after successfully joining a DApp, a participant’s
user transaction key pair will be created automatically by BSN by default. The participant’s
off-BSN system can use the participant’s UserCode to invoke the certificate generated by
the key pair. If the participant’s off-BSN system has multiple sub-users, the off-BSN
system can invoke the gateway’s “User Registration API” to register the sub-users and
generate separate user transaction key pair for each sub-user. The sub-users can use their
UserCode to connect to the DApp to execute transactions.
47
Blockchain-based Service Network User Manual
Transaction process:
⚫ DApp Access Key Pair: The DApp participant must generate the DApp access key pair
locally according to the DApp framework algorithm after successfully joining the DApp.
The participant stores the private key locally and uploads the public key to BSN via the
BSN global portal. The participant’s off-BSN system uses the private key to sign the
transaction messages when invoking the PCN gateway. The PCN gateway will use the
public key uploaded by the participant to verify the signature and validate the legality of
the transaction.
⚫ User Transaction Key Pair: This is the identity of a participant to invoke the chaincodes.
Under the Key Trust Mode, the participant must generate the user transaction key pair
locally and use the public key to generate the “public key registration application.”, then
from the participant’s off-BSN system to submit the registration application to BSN by
invoking the “Public Key Upload Mode user certification registration” API on the PCN
gateway to receive the public key certificate. If the off-BSN system has sub-users, it should
first invoke the “User Registration” API to register the sub-users before sending their public
key registration applications.
48
Blockchain-based Service Network User Manual
Transaction process:
Off-BSN
PCN Gateway
System
3. Assemble
Transaction
Parameters
4. Invoking "Public Key Upload Mode
Invoking Chaincode" API
1. Interface address:
https://PCNgatewayAddress/api/app/getAppInfo
Example:
49
Blockchain-based Service Network User Manual
{"header":{"userCode":"USER0001202004151958010871292","appCode":"app0001202
004161020152918451","tId":""},"mac": "","body":{}}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature value mac String Y
Header
0: successful
1 Response ID code int Y
-1: failed
2 Response Message msg String Y
Body
1 DApp name appName String Y
2 DApp type appType String Y
1: Key Trust Mode
DApp encryption
3 caType Int Y 2: Public Key Upload
key type
Mode
DApp algorithm algorithmTy 1: SM2
4 Int Y
Type pe 2: ECDSA (secp256r1)
5 City MSPID mspId String Y
Fabric corresponding
6 DApp chain name channelId String Y channelId, fisco
corresponding groupId
Example:
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQDE9zv0E/w4V/ILG6wUCFP08a7NDCAtX/IoZOcCyY4gIQIgUTYWsFTA1KE8
8gE6452jKnnVBrhznGVOV2HPMCbNh8A=",
"body": {
"appName": "sdktest",
"appType": "fabric",
"caType": 2,
"algorithmType": 2,
"mspId": "OrgbNodeMSP",
"channelId": "app0001202004161020152918451"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/user/register
50
Blockchain-based Service Network User Manual
51
Blockchain-based Service Network User Manual
"secret": "123456"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/reqChainCode
This interface will directly return the response message without waiting for the generation of
block. Please use “Get transaction information API” described in section 5.4.3.8 to check the
status of a block generated based on transaction ID.
Note: After a user has successfully participated in a DApp service, this participant can view
and download the DApp’s configuration parameters which are used for off-BSN systems to
connect to this DApp’s chaincodes, including the PCN gateway address and Dapp access keys,
as shown below:
52
Blockchain-based Service Network User Manual
mapping ID
Body
1 user name userName String N
Use 24 random byte array
random string nonce String Y
of the base64 encoding
1 chainCode chainCode String Y
2 function name funcName String Y
3 Call parameters args String[] N
Map<str
4 Transient data transientData ing,strin N
g>
Example:
{"header":{"userCode":"USER0001202004161009309407413","appCode":"app0001202004
161017141233920","tId":""},"mac":"MEQCICJpE1jfeJKtw/ZboVuKSLy2RmmSdkhrEVPG
FJhm9IaIAiA/Qqs6RNz0ndSS4/AFSwBj7vC76Py1hXnqO5zMD9pNtA==","body":{"userN
ame":"","nonce":"lgH7Ozfv6npqg9D3pSbq9c6o+rAcpa5D","chainCode":"cc_app000120200
4161017141233920_00","funcName":"set","args":["{\"baseKey\":\"test2020048\",\"baseValu
e\":\"this is string \"}"],"transientData":{}}}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
Signature
3 mac String Y
Value
Header
0: authentication successful
1 Response ID code int Y
-1: authentication failed
Response
2 msg String N if code=0 then can be null
Message
Body
block If code is not 0, then leave
1 blockInfo blockInfo N
information blank
chaincode
If code is not 0, then leave
2 response ccRes ccRes N
blank
result
blockInfo
Transaction
1 txId String Y
ID
On synchronous mode
2 Block HASH blockHash String N
returns Block HASH
Refer to the detailed
3 status value status Int Y transaction status
description in 5.4.3.17
ccRes
chaincode
200: Successful
1 response ccCode Int Y
500: Failed
status
chaincode
Actual chaincode response
2 response ccData Str N
result
result
Example
{
"header": {
53
Blockchain-based Service Network User Manual
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQCBtfO1AfYkoJ2hIlp8CfKK1iuhVEAYkPY8YFRAdvPJlAIgDjSqYgwlORJRyF6
KZPU/uC5Fx/DxXxu9VgKwU9+JhjU=",
"body": {
"blockInfo": {
"txId": "a144149150ee615a9d11c68485600f43dc2c3eb2a98d7b36de53a6b99e03c495",
"blockHash": "",
"status": 0
},
"ccRes": {
"ccCode": 200,
"ccData": "SUCCESS"
}
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/user/enroll
54
Blockchain-based Service Network User Manual
55
Blockchain-based Service Network User Manual
END CERTIFICATE-----\n"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/trans
56
Blockchain-based Service Network User Manual
bWFXeHBZWFJwYjI0aU9pSnZjbWRpYm05a1pTNWljMjVpWVhObExtTnZiU0lzCkl
taG1Ma1Z1Y205c2JHMWxiblJKUkNJNkluUmxjM1F3TWtCaGNIQXdNREF4TWpBe
U1EQTBNVFl4TURJd01UVXkKT1RFNE5EVXhJaXdpYUdZdVZIbHdaU0k2SW1Oc
2FXVnVkQ0lzSW5KdmJHVWlPaUpqYkdsbGJuUWlmWDB3Q2dZSQpLb1pJemowR
UF3SURSd0F3UkFJZ1ZZNi9jZ1NDTmpENkxwTXVaZEQzVWYvWko5c3FSUVVT
R3hSQU9SeGZONThDCklFN0JHTDljOHRCcHJiVmpYTldtQmpObWhqeUE3N0l3S
W8rbUg1ZXp4R1B1Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KEhiQKmgB1Ibwb
gLAyoHXUNnjZSGOqBDheQMSbQprCmkIARIkEiJjY19hcHAwMDAxMjAyMDA0
MTYxMDIwMTUyOTE4NDUxXzAwGj8KA3NldAo4eyJiYXNlS2V5IjoidGVzdDIw
MjAwNDA0IiwiYmFzZVZhbHVlIjoidGhpcyBpcyBzdHJpbmcgIn0SRjBEAiB+mOUK
Y7fRjcZ1/qc96YP9GGod3UK56jJaWaE4o3J90QIgeirrjyzL6zQLN89tv3jDpI7vxKChk
GM9u8IEFiFEGYo="}}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
Signature
3 mac String Y
Value
Header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response
2 msg String N If code=0, can be null
Message
Body
block If code is not 0, then
1 blockInfo blockInfo N
information leave blank
chaincode If code is not 0, then
2 ccRes ccRes N
response result leave blank
blockInfo
1 Transaction Id txId String Y
On synchronous mode,
2 Block HASH blockHash String N
returns Block HASH
refer to detailed
3 status value status Int Y transaction status
description in 5.4.3.17
ccRes
chaincode 200: successful
1 ccCode Int Y
response status 500: failed
chaincode actual chaincode
2 ccData Str N
response result response result
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEQCICXNk40O+Gkqqe2XgoaxdOoIvDQe4RfLtwXkxjC7ce8TAiBLVu6PjOqWueV
B3t4h7REpNdcVf6L0qVzfdA1yovuc7g==",
"body": {
"blockInfo": {
57
Blockchain-based Service Network User Manual
"txId":
"c3c6523958c3811192b8d358dd2617f1b14cb661de6b022c1a822269e8a8c48d",
"blockHash": "",
"status": 0
},
"ccRes": {
"ccCode": 200,
"ccData": "SUCCESS"
}
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/getTransaction
58
Blockchain-based Service Network User Manual
message be null
Body
1 Block Hash blockHash String Y
Block
2 blockNumber Long Y
Number
refer to detailed
Transaction transaction status
3 status Int Y
status description in
5.4.3.18
on-chain
4 createName String Y
user name
Timestamp “second” in the
5 timeSpanSec Int64 Y
Second timestamp
Timestamp “nanosecond” in
6 timeSpanNsec Int64 Y
Nanosecond the timestamp
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQDUFw5pa4QJcEiQjYeLTl2L94HbsZbz7DArF+djgzWoTQIgU8u+dG6CcHw
BZjuf9PvhYdEFAa/ujwo8UAPbAmKxRq0=",
"body": {
"blockHash":
"ab9366cf63881228863c884527fceefabc9ad2e375aa0bcbf71f17f75c7d3ff5",
"blockNumber": 7,
"status": 0,
"createName": "test02@app0001202004161020152918451",
"timeSpanSec": 1587445821,
"timeSpanNsec": 249139700
}
}
5.4.3.9 Get transaction data API
This interface can be used by off-BSN systems to obtain transaction information based on the
transaction ID and then returns the string of the transaction information by base64 encryption.
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/getTransdata
4. Call parameters
59
Blockchain-based Service Network User Manual
60
Blockchain-based Service Network User Manual
gateway to get the block information of the current transaction (body.blockInfo), the status
(body.blockInfo.status), and transaction ID (body.blockInfo.txId). If the status value is 0, it
signifies that the transaction has been successful and a block has been created. The block
information can be queried according to the transaction ID.
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/getBlockInfo
5. Response parameters
No. Field name Field Type Required Remarks
1 header header Map Y
2 body body Map Y
3 signature value mac String Y
Header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can
2 msg String N
Message be null
Body
1 Block Hash blockHash String Y
2 Block Number blockNumber Long Y
Previous Block
3 preBlockHash String Y
Hash
61
Blockchain-based Service Network User Manual
1. Interface address:
62
Blockchain-based Service Network User Manual
https://PCNGatewayAddress/api/fabric/v1/node/getBlockData
Response parameters
No. Field name Field Type Required Remarks
1 header header Map Y
2 body body Map Y
3 signature value mac String Y
Header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can
2 msg String N
Message be null
Body
1 Block Hash blockHash String Y
2 Block Number blockNumber Long Y
Previous Block
3 preBlockHash String Y
Hash
String generated
4 Block Data blockData String Y by base64
calculation
Example
{
"header": {
"code": 0,
63
Blockchain-based Service Network User Manual
"msg": "success"
},
"mac":
"MEQCICAgU3G6o1Ky6UeYgqEgCee27TS2F8ScH+jaSj6w20OCAiB+/6z1a2jG5m4vvjz1ft
2LQdIsaG2BAXqcwxmSFyEIzg==",
"body": {
"blockHash":
"b8366a63ed32fddec720872d206802e670222f29d9a8a32983d26b59dbfd6971",
"blockNumber": 3,
"preBlockHash":
"6dcc69799682e2fc7ffa950c56031b807c54b7a098b4fd69db9cf8c97518bcea",
"blockData": "CkYIAxIgbcxpeZa..............."
}
}}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/node/getLedgerInfo
64
Blockchain-based Service Network User Manual
Body
1 Block Hash blockHash String Y
2 Block Height height Long Y
Previous Block
3 preBlockHash String Y
Hash
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQC4PhYTBNyt1rSeBeZTdOly42CxILVgK1b/RlieA33G1gIgeodoEa5Ou0X4uW
c/VGp0n6NKByhXlBbo22FME4xQ8aw=",
"body": {
"blockHash":
"ab9366cf63881228863c884527fceefabc9ad2e375aa0bcbf71f17f75c7d3ff5",
"height": 8,
"preBlockHash":
"fc83c306677925efee540b4d7b7ca73e06f144cae34c706f1101d6b395ada2da"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/chainCode/event/register
65
Blockchain-based Service Network User Manual
{"header":{"appCode":"CL20191107112252","userCode":"lessing"},"body":{"attachArgs
":"name=TOM&age=20","chainCode":"cc_bsn_test_00","eventKey":"test01","notifyUrl":
"http://192.168.6.128:8080/api/event/notifyUrl"},"mac":"MEUCIQCjzPr4KZVild2Vm5Y
gcunOXTh9mQK2QfWcRnYCk+jOzgIgDW6oHca7/249M43p2ElwiMNbuejdwAnyW5O
wiMqiWCQ="}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: successful
1 Response ID code int Y
-1: failed
Response
2 msg String Y
Message
Body
1 Event ID eventId String Y
Example
{ "header": { "code": 0, "msg": "Event Registration Successful" }, "body":
{ "eventId": "bd3391deedbe44a7ad5b7f80ce59abfa" }, "mac":
"MEQCIENLpj2R9mRL100vcMXs0X5rwfSjB/U7kMg+76GjEPNJAiBlUo/Eyj49uXTPrz
RW0m4rJ0NQIkZnDMPbyalxojXwrA=="}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/chainCode/event/blockRegister
66
Blockchain-based Service Network User Manual
01202101191411238426266","tId":""},"mac":"MEUCIQClsjKy/ee1qaYrItzCO1b
Mfjs0g0kPu8+YOCjbk3rPRAIgSfeyYvfeoh8QciZPG4fZQepaiyh7PmmWjYzFSq
ylT/c=","body":{"chainCode":"","eventKey":"","notifyUrl":"http://192.168.6.78:5
8011/v1/fabric/test","attachArgs":"a=1"}}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: successful
1 Response ID code int Y
-1: failed
Response
2 msg String Y
message
Body
1 Event ID eventId String Y
Example
{
"header": {
"code": 0,
"msg": "success"
},
"mac":
"MEUCIQC6PKsSqfkQGLrqi2vMpZzBP5beLhyP+fXVr8S5aqhaagIgaEtAnsuiub
ibYoYZzQ/8aGYErzm5rtU8Oj952OuHgCo=",
"body": {
"eventId": "002f0e1f0b0f4331ab541461547a38d6"
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/chainCode/event/query
67
Blockchain-based Service Network User Manual
68
Blockchain-based Service Network User Manual
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/chainCode/event/remove
69
Blockchain-based Service Network User Manual
After receiving the notification successfully, the off-BSN system returns a string containing
“success”, otherwise, the gateway will send the notification again at 3, 12, 27, and 48 seconds
respectively, for a total of five times.
70
Blockchain-based Service Network User Manual
Null when
11 Previous hash previousHash String N chaincode event
notification
Example:
Chaincode event nofitication
{"header":{"userCode":"lessing","appCode":"CL20191107112252"},"body":{"cha
inCode":"cc_bsn_test_00","orgCode":"ORG1571365934172","eventKey":"test:\\S
{32}","eventId":"2964a0f60b3e460f834618b3664af2da","attachArgs":"abc=12321
1","eventName":"test:12345678123456781234567812345678","txId":"32fc10568
1820fa556b8a460efc1e43a47daa864b959ea1753abb4640f2dce49","payload":"","b
lockNumber":74,"nonceStr":"522c8061b5e84837bad72ca08c6a353f"},"mac":"ME
QCIDU4tROyjLtvD1b8TTbWWAlCPuUbmdPAEUXwRRgVn7kIAiA58je5u/7x
DuRPcgeUWL3nB9mouUGQ6dGKJMmD7Jm08g=="}
{"header":{"userCode":"USER0001202007101641243516163","appCode":"app00
01202101191411238426266"},"body":{"orgCode":"ORG2020041114171692360"
,"eventId":"8746bb9a1e854c9f8b3710f5a63f7c59","attachArgs":"a=1","previousH
ash":"022281f6089e3684501251775166b6b0afd18a176ec98a835cb5d09aff0d4950
","blockNumber":12,"nonceStr":"79a7baa26c854caeb2e2e7abc0b7f07e"},"mac":"
MEUCIQDiZrwf8fKG/3fuaVrsfTN3BKmLx+qnnEuuSaHfvIBbMQIgS+1qHKXe
VR24WXwOGu3Nze/tLLziQ0LkjXaueYu0ctM="}
4. The payload parameter in the message is not passed in Fabric 1.4.3, please refer to
https://github.com/hyperledger/fabric/blob/v1.4.3/core/peer/deliverevents.go#L251
For the specific code, if you need to use the payload parameter, you can get it as follows:
1) store the content to be passed through the event to the chain in the form of “key-value”.
2) pass the event name and the key splice in 1 as eventName, e.g.: eventkey_key.
3) register the event with a regular registration, e.g. : eventkey_[\s\S]*.
4) after receiving the event, parse the key according to the event name and call a query to
get the value.
5) if the amount of payload data to be passed is not large, it can be directly spliced to
enevtName, which has no length limitation.
5.4.3.18 Transaction status description
Under both Key Trust Mode and Public Key Upload Mode, the description of the returned
transaction status when the off-BSN system invokes the DApp chaincodes via PCN gateway
APIs are shown as follows:
71
Blockchain-based Service Network User Manual
72
Blockchain-based Service Network User Manual
3. Signature rules
1. FISCO BCOS framework DApp using ECDSA (secp256k1) secret key algorithm
• Getting the Hash value: The converted string to be signed is required to be computed
with SHA256 algorithm with UTF-8 encoding.
• Sign the Hash value: The hash value and private key should be encrypted with ECDSA
(secp256k1) algorithm. In the processing of some programming languages (C#, Java),
if signed with SHA256WithECDSA, which includes hash value computation, therefore,
the first step is not necessary.
• Encoding the signature result to Base64.
2. FISCO BCOS framework DApp using SM secret key algorithm
• Getting the Hash value: The converted string to be signed is required to be computed
with SM3 algorithm with UTF-8 encoding.
• Sign the Hash value: The hash value and private key should be encrypted with SM2
algorithm.
• Encoding the signature result to Base64.
4. Example
Parameters:
{"header":{"userCode":"user01","appCode":"app01"},"mac":"","body":{“userId”:”abc”,”list
”:[“abc”,”xyz”]}}
Result: user01app01abcabcxyz
DApp Access Key Pair: After the participant has successfully joined the DApp, BSN will
generate one key pair (private and public keys) that corresponds to the DApp’s framework
algorithms under the Key Trust Mode. The participant can download the private key from “My
Certificates” section of the BSN global portal and use it to sign the request message sent to the
PCN gateway. The gateway will use the hosted public key from the generated key pair to
validate the signature.
User Transaction Key Pair: This is the identity of a participant to invoke the chaincodes. Under
the Key Trust Mode, after successfully joining the DApp, a participant’s user transaction key
pair will be created automatically by BSN by default. The participant’s off-BSN system can
use the participant’s UserCode to invoke the certificate generated by the key pair. If the
participant’s off-BSN system has multiple sub-users, the off-BSN system can invoke the
gateway’s “User Registration API” to register the sub-users and generate a separated user
transaction key pair for each sub-user. The sub-users can use their own UserCode to connect
to the DApp to execute smart contract transactions.
73
Blockchain-based Service Network User Manual
Transaction process:
⚫ DApp Access Key Pair: The DApp participant must generate the DApp access key pair
locally according to the DApp framework algorithm after successfully joining the DApp.
The participant stores the private key locally and uploads the public key to BSN via the
BSN global portal. The participant’s off-BSN system uses the private key to sign the
transaction messages when invoking the PCN gateway. The PCN gateway will use the
public key uploaded by the participant to verify the signature and validate the legality of
the transaction.
⚫ User Transaction Key Pair: This is the identity of a participant to invoke the chaincodes.
Under the Key Trust Mode, the participant must generate the user transaction key pair
locally and use the public key to generate the “public key registration application”, then
from the participant’s off-BSN system to submit the registration application to BSN by
invoking the “Public Key Upload Mode user certification registration” API on the PCN
gateway to receive the public key certificate. If the off-BSN system has sub-users, it should
first invoke the “User Registration” API to register the sub-users before sending their public
key registration applications.
Transaction process:
74
Blockchain-based Service Network User Manual
Off-BSN
PCN Gateway
System
3. Assemble
Transaction
Parameters
4. Invoking "Public Key Upload Mode
Invoking Chaincode" API
1. Interface address:
https://PCNgatewayAddress/api/app/getAppInfo
Example:
{"header":{"userCode":"USER0001202004151958010871292","appCode":"app0001202
004161020152918451","tId":""},"mac": "","body":{}}
75
Blockchain-based Service Network User Manual
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature value mac String Y
Header
0: successful
1 Response ID code int Y
-1: failed
2 Response Message msg String Y
Body
1 DApp name appName String Y
2 DApp type appType String Y
1: Key Trust Mode
DApp encryption
3 caType Int Y 2: Public Key
key type
Upload Mode
1: SM2
DApp algorithm algorithmTy
4 Int Y 2:
Type pe
ECDSA(secp256r1)
5 City MSPID mspId String Y
Fabric
corresponding
6 DApp chain name channelId String Y channelId, fisco
corresponding
groupId
Example:
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQDE9zv0E/w4V/ILG6wUCFP08a7NDCAtX/IoZOcCyY4gIQIgUTYWsFTA1
KE88gE6452jKnnVBrhznGVOV2HPMCbNh8A=",
"body": {
"appName": "sdktest",
"appType": "fabric",
"caType": 2,
"algorithmType": 2,
"mspId": "OrgbNodeMSP",
"channelId": "app0001202004161020152918451"
}
}
5.4.4.4 User Registration API
After a participant has successfully joined in a FISCO BCOS (FISCO) DApp, his/her off-BSN
system can invoke this interface to generate the user account and user address to execute smart
contract transactions.
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/user/register
76
Blockchain-based Service Network User Manual
4. Call parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
1 user unique ID userCode String Y
2 DApp unique ID appCode String Y
body
1 user name userId String Y Registered
user name
Example:
{
"header":{"appCode":"CL1881038873220190902114314","userCode":"newuser"},
"body":
{
“userId”:”abc”
},
"mac":"MEQCIBRhaM2szckWl9N9qcqnaYXOXGQw7SfII9DlRvxcI3YVAiBt4XeNs+
EUjhBNSr3IjLRPZucsuGHxfjt9RiaNIQS8cA=="}
signature value:
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
Signature
3 mac String Y
Value
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can
2 msg String N
Message be null
body
User If code is not 0,
1 data []string N
information then leave blank
data
1 User ID userId String Y
2 User Address userAddress String Y
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEQCIEI5VKMyJUXls2Hf8TLoPXjZLT4/L2wyXoddgTnZdqRsAiBxEBMeCOZ8M97
OCRUAMZNMcL974vhzjOS/tk8/wbgbsA==",
"body": {
"userId": "100003",
"userAddress": "0x14647a48303b5e1c77934583883ebc327ba3b297"
}
77
Blockchain-based Service Network User Manual
}
5.4.4.5 Invoke Smart Contract API in Key Trust Mode
For the FISCO DApps in Key Trust mode, when the off-BSN system invokes the smart contract
via PCN gateway, it is required to include the parameters in the request. The gateway will
return the response message from the chaincode.
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/reqChainCode
Note: After a participant has successfully joined in a FISCO DApp service, the participant can
view and download the DApp’s configuration parameters which are used for off-BSN systems
to connect to this DApp’s smart contracts, including the PCN gateway address and Dapp access
keys, as shown below:
78
Blockchain-based Service Network User Manual
Example:
{"header":{"appCode":"cl0006202003181926573677572","userCode":"USER00062020
03181951281835816"},"body":{"contractName":"HelloWorld","userId":"100003","func
Name":"set","funcParam":[\"abc\"]},"mac":"MEUCIQDTFe2Gerdf7YJrG1a1Yt99M0Z
Q3T1lGpsXdNmFV7WuTgIgSkZ19abUhAJbMrJMBoD8N7f26xhpQRuR4vNAfY7EE
bs="}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can be
2 msg String N
Message null
Body
1 Invoke Type constant Bool N
Query If Constant is true, this
2 queryInfo String N
information field has value.
If Constant is false,
Transaction
3 txId string N this field has value and
hash
is valid.
If Constant is false,
4 Block HASH blockHash String N this field has value and
is valid.
If Constant is false,
5 Block Number blockNumber Int N this field has value and
is valid.
If Constant is false,
6 Gas Used gasUsed Int N this field has value and
is valid.
If Constant is false,
this field has value and
is valid. 0x0 means
Transaction
7 status String N transaction successful,
Status
status value refer to
transaction receipt
status in 7.3.9
If Constant is false,
8 From account from String N this field has value and
is valid.
If Constant is false,
9 To account to String N this field has value and
is valid.
If Constant is false,
10 Input input String N this field has value and
is valid.
If Constant is false,
11 Ouput output String N this field has value and
is valid.
79
Blockchain-based Service Network User Manual
Example
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/trans
Note: After a participant has successfully joined in a FISCO DApp service, the participant can
view and download the DApp’s configuration parameters which are used for off-BSN systems
to connect to this DApp’s smart contracts, including the PCN gateway address and Dapp access
keys, as shown below:
80
Blockchain-based Service Network User Manual
Name
Transaction
2 transData String Y
Data
3 Contract address contractAddress String N
4 Contract ABI contractAbi String N
Example:
{"header":{"userCode":"USER0001202006042321579692440","appCode":"app0001202
006042323057101002","tId":""},"mac":"MEUCIQCrjIeRVSt1uwFFGkr37bVM8pF0Jg
AWb40mKEBc5HbpjgIgEzXRIgG+Q7obwuD2MY4EHo9sIsI1W71M+aQKOfAN3wU
=","body":{"contractName":"BsnBaseContractk1","transData":"0xf9016fa008d8ebcb4b
1f8205fd7883aa3ce9b9c844424070e55a3af6a5da5d7ee97d287385051f4d5c0083419ce0
7794866aefc204b8f8fdc3e45b908fd43d76667d7f7680b8e4ebf3b24f0000000000000000
00000000000000000000000000000000000000000000006000000000000000000000000
00000000000000000000000000000000000000005000000000000000000000000000000
00000000000000000000000000000000a00000000000000000000000000000000000000
00000000000000000000000000573303630340000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000026161000000000000000000000000000000000000000000000000000000
000000018187801ba0324efc9e17f1d31d95535c5103083560560f836931945d03fb69acb
6fd2046b5a05fa6f574f83b3b753c9fe40649a08c2a497af1cd804e08fed2b153af20267f23"
,
"contractAddress":"0xe2d0d414d436d8be9d52e2f40e6dd24a63faa638","contractAbi":"
Contract ABI"}}
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can be
2 msg String N
Message null
Body
1 Invoke Type constant Bool N
Query If Constant is true,
2 queryInfo String N
information this field has value.
If Constant is false,
Transaction
3 txId string N this field has value
hash
and is valid.
If Constant is false,
4 Block HASH blockHash String N this field has value
and is valid.
If Constant is false,
5 Block Number blockNumber Int N this field has value
and is valid.
If Constant is false,
6 Gas Used gasUsed Int N this field has value
and is valid.
Transaction If Constant is false,
7 status String N
Status this field has value
81
Blockchain-based Service Network User Manual
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getTxReceiptByTxHash
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
82
Blockchain-based Service Network User Manual
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getTxinfoByTxHash
83
Blockchain-based Service Network User Manual
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then can be
2 msg String N
Message null
Body
Transaction
txId String
HASH
Block HASH blockHash String
Block Number blockNumber Int
Gas Used gasUserd Int
From account from String
To account to String
value Int
input String
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEQCIBMqntmqQqZXkBbrLhmXEcuOqTG4YWvlfGJmebzEDbzcAiAKKHut9MBShqpSAEo8
ts2MEQCIBMqntmqQqZXkBbrLhmXEcuOqTG4YWvlfGJmebzEDbzcAiAKKHut9MBShqpSAE
o8ts2+OBIRmEEbedjihix5FZZvrw==",
"body": {
"blockHash":
"0x199eca276b60473dd65f8b36641684456694b419d89ef41b4953a9cdac848305",
84
Blockchain-based Service Network User Manual
"input":
"0x60806040523480156200001157600080fd5b506110016000806101000a81548173fffffffffffffffff
fffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008090549061
01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c92a780
16040805190810160405280600681526020017f745f6261736500000000000000000000000000000
000000000000000000000008152506040518263ffffffff167c0100000000000000000000000000000
0000000000000000000000000000281526004016200010191906200024a565b60206040518083038
1600087803b1580156200011c57600080fd5b505af115801562000131573d6000803e3d6000fd5b50
5050506040513d601f19601f8201168201806040525062000157919081019062000174565b506200
02f4565b60006200016c8251620002a3565b905092915050565b6000602082840312156200018757
600080fd5b600062000197848285016200015e565b91505092915050565b6000620001ad82620002
98565b808452620001c3816020860160208601620002ad565b620001ce81620002e3565b60208501
0191505092915050565b6000601382527f626173655f6b65792c626173655f76616c7565000000000
000000000000000006020830152604082019050919050565b6000600782527f626173655f6964000
000000000000000000000000000000000000000000000006020830152604082019050919050565b6
0006060820190508181036000830152620002668184620001a0565b9050818103",
"gasUsed": 100000000,
"blockNumber": 1,
"txId": "0x8ee0c68e222742b5b70878265d3fdbd3a8e0d549da42a298a4ae872ca4fbfd89",
"from": "0x08ac3132a6c7e6ca5a7fbaf0521bb8b6f370ed35",
"to": "0x0000000000000000000000000000000000000000",
"value": 0
}
}
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getBlockInfo
85
Blockchain-based Service Network User Manual
cannot be null
Example:
{
"header":{"appCode":"CL1881038873220190902114314","userCode":"newuser"},
"body":
{
"blockNumber":22,
"blockHash":"0xf27ff42d4be65329a1e7b11365e190086d92f9836168d0379e92642786db7
ade"
},
"mac":"MEQCIBRhaM2szckWl9N9qcqnaYXOXGQw7SfII9DlRvxcI3YVAiBt4XeNs+E
UjhBNSr3IjLRPZucsuGHxfjt9RiaNIQS8cA=="}
signature value:
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then
2 msg String N
Message can be null
Body
Block HASH blockHash String Y
Block Number blockNumber Int Y
Parent Block parentBlockHa
String Y
HASH sh
Block Size blockSize Int Y
Timestamp in
Block Time blockTime Int Y millisecond
format
author String Y
Transaction []Transaction
transactions Y
Information Data
TransactionData
Transaction Id txId String Y
Block HASH blockHash String Y
Block Number blockNumber Int Y
Gas Used gasUsed Int Y
from String Y
to String Y
value Int Y
input String Y
Example
{
"header": {
"code": 0,
"msg": "Transaction successful"
},
"mac":
86
Blockchain-based Service Network User Manual
"MEQCIHX8SuEn/sDiPscd5li3X1GdseyggAyC2o9L92FjhzrfAiBLyFW/rguLkqz/Lz62Vt
X3m7Y1nHqcFqcNdM7Wq0wGLQ==",
"body": {
"blockHash":
"0x199eca276b60473dd65f8b36641684456694b419d89ef41b4953a9cdac848305",
"blockNumber": 1,
"parentBlockHash":
"0xa6886f12ee91470e35546432413ed372615f8d4c23fa82e8381b3e5b31219d4c",
"blockSize": 0,
"blockTime": 1587125168039,
"transactions": [
{
"txId":
"0x8ee0c68e222742b5b70878265d3fdbd3a8e0d549da42a298a4ae872ca4fbfd89",
"blockHash":
"0x199eca276b60473dd65f8b36641684456694b419d89ef41b4953a9cdac848305",
"blockNumber": 1,
"gasUsed": 100000000,
"from": "0x08ac3132a6c7e6ca5a7fbaf0521bb8b6f370ed35",
"to": "",
"value": 0,
"input":
"0x60806040523480156200001157600080fd5b506110016000806101000a81548173ffffffff
ffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060
00809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673fffffffffffffffffffffffffffff
fffffffffff1663c92a78016040805190810160405280600681526020017f745f6261736500000
000000000000000000000000000000000000000000000008152506040518263ffffffff167c0
10000000000000000000000000000000000000000000000000000000002815260040162000
10191906200024a565b602060405180830381600087803b1580156200011c57600080fd5b5
05af115801562000131573d6000803e3d6000fd5b505050506040513d601f19601f82011682
01806040525062000157919081019062000174565b50620002f4565b60006200016c825162
0002a3565b905092915050565b6000602082840312156200018757600080fd5b6000620001
97848285016200015e565b91505092915050565b6000620001ad8262000298565b80845262
0001c3816020860160208601620002ad565b620001ce81620002e3565b6020850101915050
92915050565b6000601382527f626173655f6b65792c626173655f76616c756500000000000
0000000000000006020830152604082019050919050565b6000600782527f626173655f696
40000000000000000000000000000000000000000000000000060208301526040820190509
19050565b60006060820190508181036000830152620002668184620001a0565b905081810
360208301526200027b8162000213565b90508181036040830152000000"
}
]
}
}
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getBlockHeight
87
Blockchain-based Service Network User Manual
4. Call parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
1 user unique ID userCode String Y
2 DApp unique ID appCode String Y
body
Example:
{"header":{"appCode":"cl0006202003181926573677572","userCode":"USER000620200318195
1281835816"},"body":{},"mac":"MEQCIHb2o7hb0apDukOQBXkZftETsizDBaftnHxO9A9ux5
EtAiABuiFrVYPWT5FiU+Wd9HpXF/AJh0Yh2SXtL6h98m4eZw=="}
signature value:
5. Response parameters
No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
header
0: authentication
successful
1 Response ID code int Y
-1: authentication
failed
Response if code=0 then
2 msg String N
message can be null
Body
If code not 0, then
1 Block Height data string N
leave blank
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEQCICtCOdv4ZL72M3WoA9nAei2P0/PpKjlgI0Y5qeuzg61uAiA9D3TcB/+b2RMu
NwVq+X0vgiglHfM5NBhoTJPR0gCPMA==",
"body": {
"data": "4"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getTxCount
88
Blockchain-based Service Network User Manual
89
Blockchain-based Service Network User Manual
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/node/getTxCountByBlockNumber
Example
{
"header": {
"code": 0,
"msg": "Transaction Successful"
},
"mac":
"MEUCIQCMFbVhfH9X8pJ1mNI3YpzKIBcXCpfmf2AniF/42ak9EwIgTWDEF+xW5l39
ZDUnDSSSc8Zv8J1glEf9izp16eW/Rn4=",
90
Blockchain-based Service Network User Manual
"body": {
"data": "1"
}
}
1. Interface address:
https://PCNGatewayAddress/api/fiscobcos/v1/event/register
91
Blockchain-based Service Network User Manual
1. Interface address:
https://PCNGatewayAddress/api/fiscobocs/v1 /event/query
5. Response parameters
92
Blockchain-based Service Network User Manual
93
Blockchain-based Service Network User Manual
}
],
"contractEvent": [
{
"eventId": "ba537419953e4e219ceb0fe26ad5e126",
"appCode": "app0001202006042323057101002",
"userCode": "USER0001202006042321579692440",
"notifyUrl": "http://127.0.0.1:18080",
"attachArgs": "abc=123",
"createTime": "0001-01-01 00:00:00.000 +0000 UTC",
“contractAddress”:” 0x866aefc204b8f8fdc3e45b908fd43d76667d7f76”
}
]
}
}
1. Interface address:
https://PCNGatewayAddress/api/fabric/v1/chainCode/event/remove
94
Blockchain-based Service Network User Manual
After receiving the notification successfully, the off-BSN system returns a string containing
“success”, otherwise, the gateway will send the notification again at 3, 12, 27, and 48 seconds
respectively, for a total of five times.
95
Blockchain-based Service Network User Manual
eStr":"52f080f27ff045eb87e21812d12cee40","eventType":1,"eventData":"{\"appId\":\"app000120
2006042323057101002\",\"blockNumber\":17,\"eventType\":1,\"groupId\":135}"},"mac":"MEUCI
QD3Sp6xuI4DHy/GOb9z3nH6kQisEzfXvZ/Hn/mfZXIAOgIgYsISRfBKSJGt4FrmxETflfR4A8Ve
nCZHvxthMFUWRkc="}
status(Decimal/
message Explanation
Hexadecimal)
0(0x0) None No Error
1(0x1) Unknown Unknown Error
2(0x2) BadRLP Invalid RLP Error
3(0x3) InvalidFormat Invalid Format Error
The length of smart contract exceeds gas
4(0x4) OutOfGasIntrinsic limit/smart contract invoking parameters
exceed gas limit
5(0x5) InvalidSignature Invalid Signature Error
6(0x6) InvalidNonce Invalid nonce Error
7(0x7) NotEnoughCash Not enough cash Error
8(0x8) OutOfGasBase Parameters too long (RC version)
9(0x9) BlockGasLimitReached Gas limit reached Error
10(0xa) BadInstruction Bad Instruction Error
11(0xb) BadJumpDestination Bad Jump Destination Error
Out of gas to execute the smart contract/the
12(0xc) OutOfGas
length of smart contract exceeds the limit.
13(0xd) OutOfStack Out of Stack Error
14(0xe) StackUnderflow Stack Under Flow Error
15(0xf) NonceCheckFail Nonce check failed Error
16(0x10) BlockLimitCheckFail Block limit check failed Error
17(0x11) FilterCheckFail Filter check failed Error
18(0x12) NoDeployPermission No Deployment Permission Error
19(0x13) NoCallPermission Invalid call Error
20(0x14) NoTxPermission Invalid transaction Error
21(0x15) PrecompiledError Precompiled Error
22(0x16) RevertInstruction Revert Instruction Error
23(0x17) InvalidZeroSignatureFormat Invalid Signature Format
24(0x18) AddressAlreadyUsed Address Already Used Error
25(0x19) PermissionDenied Permission Denied
26(0x1a) CallAddressError Call Address does not exist Error
96
Blockchain-based Service Network User Manual
generate public key and private key locally, register user certificate, generate certificate
signature, encrypt and decrypt data, etc.
Download links:
https://github.com/BSNDA/PCNGateway-Go-SDK
https://github.com/BSNDA/PCNGateway-Java-SDK
https://github.com/BSNDA/PCNGateway-PY-SDK
https://github.com/BSNDA/PCNGateway-CSharp-SDK
➢ Fabric example
Download link:
https://github.com/BSNDA/FabricBaseChaincode
We invite experienced developers who are interested in BSN to work together to optimize the
SDK and sample packages. If you'd like to participate, please contact us on GitHub.
Go to the Permissioned Services > Testnet Services page to publish the service.
97
Blockchain-based Service Network User Manual
Click Create a Test Service and input the service name, version, and select a platform type.
Click Upload Chaincode Package to upload the chaincode or smart contract package. You
can upload multiple chaincode/smart contract packages in a permissioned DApp service.
Input the information and click Confirm to upload the package.
98
Blockchain-based Service Network User Manual
After successfully deploying the chaincode/smart contract, developers can call it from their
off-BSN systems so that they can configure and debug the functions easily.
Note: To keep the resources stable, DevOps will periodically clean up the chaincode/smart
contract packages and ledger data on the Testnet.
5.6.3 Interchain Services on BSN Testnet
A demo version of Interchain Communications Hub (ICH) is now live on the Testnet,
integrating two interchain solutions based on the relay chain mechanism: (1) Poly Enterprise
developed by Onchain Tech and (2) IRITA developed by Bianjie AI. We welcome developers
to try out and provide feedback and suggestions, and we will continue to improve the
functionality and expect to release a commercial version in 2021.
For detailed descriptions and examples of ICH services, please refer to chapter 8, "Interchain
Services"
99
Blockchain-based Service Network User Manual
6.1 Overview
BSN dedicated node services apply BSN technologies including multi-layer framework
adaptation, virtualized container, automated deployment and node gateway to provide users
with "out-of-the-box" blockchain cloud services. Users can quickly create their own dedicated
permissioned blockchain operating environment, configure node's CPU, memory, disk capacity
and other parameters in the BSN portal; they can independently manage nodes, publish smart
contracts, access node data and monitor blockchain operation status. The dedicated node does
not restrict APIs of the framework, and all APIs can be called by developers after they access
the dedicated node through the gateway.
Currently, dedicated node services allow users to build the permissioned chain services based
on ConsenSys Quorum (an open source, free and enterprise-focused blockchain framework),
Hyperledger Fabric, and Besu in the BSN public city node built on AWS cloud platform. The
version of ConsenSys Quorum is v20.10.0, and its consensus mechanism supports Raft and
IBFT mechanisms; the version of Hyperledger Fabric is v2.3.2, and its consensus mechanism
is Raft; the version of Hyperledger Besu is v21.1.2, and its consensus mechanism is Clique and
IBFT.
2. Click Create Project button and jump to the information page. This page contains 4
sections: Basic Information, Node Information, Gateway Information and Data Usage
Information.
1) Basic Information: This section shows the basic information of the service.
⚫ When the framework is ConsenSys Quorum-v20.10.0, the following basic information
will be displayed, including project name, framework, consensus mechanism (options
including: Raft, IBFT), cloud platform and region.
100
Blockchain-based Service Network User Manual
2) Node Information: The publisher can select the number of nodes and other resource
information, including CPU, memory and data capacity. The price is automatically
calculated based on the resources which publisher has selected.
⚫ When the framework is ConsenSys Quorum-v20.10.0 or Hyperledger Besu-v21.1.2,
the node information includes: Number of Nodes, Host Configuration, Data Capacity
and Price.
101
Blockchain-based Service Network User Manual
3) Gateway Information: This section shows the information of the gateway node, and
this node contains Nginx service and a blockchain browser. Publisher does not need to
select resources.
4) Data Usage Information: This section shows the unit data price for inbound gateway
traffic and outbound gateway traffic.
3. Click Next button to jump to Charge Details page. This page has 3 sections: Resource
Cost, Data Usage Information and Total Cost.
102
Blockchain-based Service Network User Manual
1) Resource Cost: Resource Cost section contains the cost of node resources and
gateway resources. According to the resource cost information, the publisher can
either pay by month or pay by year. A discount will be applied when paying annually.
⚫ When the framework is ConsenSys Quorum-v20.10.0 or Hyperledger Besu-v21.1.2,
the node information section of the resource cost includes: number of nodes, host
configuration, data capacity, and price.
⚫ When the framework is Hyperledger Fabric-v2.3.2, the node information section of
the resource cost display includes: number of nodes, number of orderers, host
configuration, data capacity, and price.
2) Data Usage Information: This section shows the unit data price for inbound gateway
data usage and outbound gateway data usage.
3) Total Cost: The total charges that the publisher should pay for.
4. After the publisher confirms the Charge details, click "Confirm" button to make payment.
The payment will be deducted from the user's personal (or corporate) account. If the
deduction fails, the bill will be kept for 72 hours before expiration. If you still want to open
a dedicated node service, you can resubmit or recreate the project by editing the current
project.
Note: In terms of dedicated node services payment, developers can make payments for
dedicated node services with the status of "not deployed" and pending payment, payment
failed, and "running" but in arrears. The payment will be debited from the user's personal
(or corporate) account. After the payment is successful, the developer should wait for the
deployment of the dedicated node.
103
Blockchain-based Service Network User Manual
2. Once edited the information, developer can jump to the Charge Details page to pay the bill.
After the payment is successfully made, developer can then wait for the deployment of the
dedicated node.
104
Blockchain-based Service Network User Manual
3) Deployment Information: The developer can view node information and browser
information. Clicking on the "Details" button corresponding to the peer node, developer
can view the information of Access and Credentials, Transaction Manager cluster, and
Default Wallet.
4) By clicking on the "Details" button corresponding to gateway services, the developer can
obtain the URL address of the blockchain browser.
105
Blockchain-based Service Network User Manual
106
Blockchain-based Service Network User Manual
4) Clicking on the "Details" button corresponding to the browser, developer can obtain the
URL address of the blockchain explorer.
107
Blockchain-based Service Network User Manual
108
Blockchain-based Service Network User Manual
4) By clicking on the "Details" button corresponding to gateway services, the developer can
obtain the URL address of the blockchain explorer.
For users who pay monthly for node and gateway resources, no refund will be generated when
unsubscribing; for users who pay annually for node and gateway resources, refunds will be
109
Blockchain-based Service Network User Manual
made at the point of time from the next month to the end of the billing cycle when unsubscribing.
The discount policy for annual payment will be cancelled and the refund will be calculated by
actual refundable months.
110
Blockchain-based Service Network User Manual
The configuration upgrade cannot delete the original node and downgrade the configuration of
the original node. It can only upgrade on the basis of the current configuration.
Go to “Permissioned Services” -> “Dedicated Node Services”, select the running service,
click “Configuration Upgrade” to enter the configuration upgrade list page as below:
In the configuration upgrade list page, click “Add” to enter the configuration upgrade
application page. The service configuration upgrade type is divided into node upgrade and
resource upgrade.
When the publisher is selecting the configuration type as node upgrade, he or she can select
the number of new nodes to be added:
111
Blockchain-based Service Network User Manual
When the publisher is selecting the configuration type as resource upgrade, he or she can select
the CPU, memory, and hard disk drive to be added in the node information and gateway
information:
Click “Confirm” to submit the application of configuration upgrade. The system will ask for
the payment of the corresponding configuration upgrade:
112
Blockchain-based Service Network User Manual
After the publisher clicks “Confirm”, the system generates a configuration upgrade bill and
debits the publisher's account. If the deduction is successful, the system will upgrade the
configuration. If the deduction fails, the bill will be retained for 72 hours before expiration, if
you still want to upgrade the configuration, you need to re-apply.
Note: The fee paid for the configuration upgrade is the upgrade fee, which is to make up the
difference between the pre-upgrade configuration and the post-upgrade configuration in the
billing cycle. After a successful upgrade, the next deduction cycle will be debited according to
the cost of new configuration.
Example:
$ ./geth attach
https://VuF0h0y7pLwtvDqjuW:y2sYuiIciR6JFtHbmC@bsnmu7d0gNn.bsngate.com:19602/no
de1
instance: Geth/v1.9.7-stable-af752518(quorum-v20.10.0)/linux-amd64/go1.13.15
coinbase: 0xf957d0ae8a1c1b2cdcea0acb8fb0a2a750abadaa
datadir: /root/quorum/data
> web3.eth.blockNumber
11
113
Blockchain-based Service Network User Manual
https://github.com/ethereum/wiki/wiki/JSON-RPC
https://docs.goquorum.consensys.net/en/latest/Reference/APIs/PrivacyAPI/
Example:
$ curl -H "Content-Type: application/json" -d
'{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}'
https://VuF0h0y7pLwtvDqjuW:y2sYuiIciR6JFtHbmC@bsnmu7d0gNn.bsngate.com:19602/no
de1
{"jsonrpc":"2.0","id":2,"result":"0x10"}
https://github.com/ChainSafe/web3.js
Example:
const Web3 = require("web3");
new
Web3.providers.HttpProvider("https://VuF0h0y7pLwtvDqjuW:y2sYuiIciR6JFtHbmC@bsn
mu7d0gNn.bsngate.com:19602/node1")
);
web3.eth.getBlockNumber().then(console.log);
Example:
➢ Start cli:
➢ # docker-compose-cli.yaml file:
➢ $ cat docker-compose-cli.yaml
➢ version: '2'
114
Blockchain-based Service Network User Manual
➢ services:
➢ cli:
➢ container_name: fabric_peercli
➢ image: hyperledger/fabric-tools:2.3.2
➢ restart: always
➢ tty: true
➢ stdin_open: true
➢ environment:
➢ - FABRIC_LOGGING_SPEC=DEBUG
➢ - CORE_PEER_TLS_ENABLED=true
➢ - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
➢ - CORE_PEER_ADDRESS=peer1.org1.example.com:1051
➢ - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp
➢ - CORE_PEER_LOCALMSPID=Org1MSP
➢ -
ORDERER_CA=/etc/hyperledger/fabric/orderer/tlsca/tlsca.orderer.example.com
-cert.pem
➢ - ORDERER_ADDRESS=orderer1.orderer.example.com:7050
➢ working_dir: /etc/hyperledger/fabric
➢ command: /bin/bash
➢ volumes:
➢ - /var/run/:/host/var/run/
➢
- ./certs/ordererOrganizations/orderer.example.com:/etc/hyperledger/fabric
/orderer
➢
- ./certs/peerOrganizations/org1.example.com/users/Admin@org1.example.com/
msp:/etc/hyperledger/fabric/msp
➢
- ./certs/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/
tls:/etc/hyperledger/fabric/tls
➢ - ./sharedfiles/chaincode:/etc/hyperledger/fabric/src
➢ extra_hosts:
115
Blockchain-based Service Network User Manual
➢ - "orderer1.orderer.example.com:161.189.69.75"
➢ - "peer1.org1.example.com:161.189.69.75"
➢ // package
➢ // install
➢ // queryinstalled
➢ // approveformyorg
➢ // queryapproved
➢ // checkcommitreadiness
➢ // commit
➢ // querycommitted
➢ // InitLedger
116
Blockchain-based Service Network User Manual
➢ // GetAllAssets
➢ // CreateAsset
➢ //UpdateAsset
➢ //ReadAsset
Example:
[root@localhost ~]# geth attach https://admin:123456@bsn91000001.bsngate.com:1
9602/node1
INFO [07-
15|13:41:24.391] Running with private transaction manager disabled - quorum pr
ivate transactions will not be supported
instance: besu/v21.1.2/linux-x86_64/oracle_openjdk-java-11
coinbase: 0xfd0fdb96a3326c61756711d314bea0149088c3d9
117
Blockchain-based Service Network User Manual
> web3.eth.blockNumber
202
>
- Example:
```shell
> '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}' \
> https://admin:123456@bsn91000001.bsngate.com:19602/node1
"jsonrpc" : "2.0",
"id" : 2,
"result" : "0x365"
```
- Example:
118
Blockchain-based Service Network User Manual
```shell
new Web3.providers.HttpProvider("https://VuF0h0y7pLwtvDqjuW:y2sYuiIciR6JFtHb
mC@bsnmu7d0gNn.bsngate.com:19602/node1")
);
web3.eth.getBlockNumber().then(console.log);
```
119
Blockchain-based Service Network User Manual
7 Permissionless Services
7.1 Overview
The Permissionless service allows the participant to select a public city node to access a plan
that can be a free plan or a premium plan. When this is done, the participant can create a project,
obtain the project ID, key and access parameters which can be used to access selected public
chain node gateway. With the Permissionless service, the default plan is free for participants,
however, it has limited daily requests and projects. BSN has created several other plans that
can be upgraded to, for a certain fee, paid on a monthly basis.
When you click and expand the public city node, you can see all public chain frameworks
supported by the city node. Users can decide whether to choose this city node as the access
entrance according to their needs. The public chain frameworks supported by different city
nodes may be different. In general, we recommend that developers choose a city node that is
close to them, so that the access speed will be relatively fast.
By default, participants on the Permissionless service have a free plan that is free to use up to
2000 daily requests, allowed TPS of 100 and maximum of 3 projects. However, a participant
can upgrade to a higher plan available on the platform. To select plans, follow these steps
120
Blockchain-based Service Network User Manual
1. On the Permissionless page, click Buy in the Select Your Plan section.
2. In the Details page, locate the Select or Update your plan section and click Buy on the
appropriate plan.
3. In the Are you sure you want to buy package window, click the project agreement and
click Confirm.
4. In the Select Payment Method page, select the appropriate payment method and click
Next Step to be redirected to Stripe.
The BSN portal never records and stores any credit card information.
121
Blockchain-based Service Network User Manual
5. On the Stripe Payment page, click Pay to display the Receipt and Invoice.
122
Blockchain-based Service Network User Manual
1. In the Permissionless Service page, click Create Project in the development plan section.
123
Blockchain-based Service Network User Manual
2. In the Create a new project window, enter the Project Name, select the Public Chain to
access from the dropdown list, input the Daily Requests number if needed. Then click
Create Project. The Daily Requests number is optional, and it is used to control the TPD
(transactions per day) for this project.
This will automatically create the project and list it in the Project Information tab.
After a project has been created it can be managed using available tools for the project. To
manage a project, follow these steps:
1. Locate the project to be managed, click Upgrade to display the Plans page.
2. Select the appropriate plan to Upgrade to and click confirm to display the payment page.
124
Blockchain-based Service Network User Manual
3. To enable the project key, in the Permissionless Service page, click Project list to display
the list of projects. In Action, click Enable Key to enable the project key. Then the
information page on enabling the key will be displayed. Click Confirm.
4. To update a project key, click Update Key. Then the information page on updating the
key will be displayed. Click Confirm.
5. To delete a project, click Delete. A confirmation message will be displayed asking if you
wanted to delete the project. Click Confirm to delete it.
125
Blockchain-based Service Network User Manual
After developers select the public chain framework (netcode) in the BSN portal to create the
public chain project, they will get the gateway’s domain name address (url), project number
(id), project key (key), public chain supportive protocol {protocol} and public chain gateway
API address.
The developer accessing the PCN gateway via HTTP should concatenate the request address
in "https://{url}/api/{id}/{netcode}/{protocol}/{subUrl}" format. If project key is enabled, "x-
APi-key:{key}"should be added to the request header. If the public chain nodes provide
multiple components, they should add {subUrl}; If the Nervos CKB has an Indexer component
service in addition to the RPC service, "{subUrl}" should fill the indexer value, {subUrl} is
optional.
The developer accessing the node gateway via WebSocket, should concatenate the Key and
SubUrl to the path address of the target machine and concatenate to the format of
{url}/api/{id}/{key}/{netcode}/{subUrl}. If the project key is not enabled, then the {key} filed
should be null. If there is no subUrl, this field can be null. That is, developers can think of the
content after/API as the method name of a target machine.
7.4.2 Ethereum
Ethereum is a global, open-source platform for decentralized applications. On Ethereum, you
can write code that controls digital value, runs exactly as programmed, and is accessible
anywhere in the world.
The BSN public city node gateway is adapted to the Ethereum JSON RPC API, so developers
can initiate transaction requests to the node gateway via HTTP JS-RPC. For detailed docking
instructions please visit: https://eth.wiki/json-rpc/API
The following table shows additional error code definitions for public city node gateways:
126
Blockchain-based Service Network User Manual
7.4.3 EOS
EOSIO is a blockchain platform designed for the real world. Built for both public and private
use cases, EOSIO is customizable to suit a wide range of business needs across industries with
rich role-based security permissions, industry-leading speeds and secure application processing.
The BSN city node gateway is adapted to EOSIO's JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://developers.eos.io/manuals/eos/latest/nodeos/plugins/chain_api_plugin/api-
reference/index#operation/get_block
The following table shows additional error code definitions for public city node gateway:
7.4.4 Nervos
The Nervos Network is an open source public blockchain ecosystem and collection of
protocols solving the biggest challenges facing blockchains like Bitcoin and Ethereum today.
The BSN city node gateway is adapted to the Nervos JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC.
https://docs.nervos.org/docs/reference/rpc
The following table shows additional error code definitions for public city node gateway:
7.4.5 NEO
127
Blockchain-based Service Network User Manual
NEO is an open-source, community driven platform that is leveraging the intrinsic advantages
of blockchain technology to realize the optimized digital world of the future.
The BSN city node gateway is adapted to the NEO JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://docs.neo.org/docs/zh-cn/reference/rpc/latest-version/api.html
The following table shows additional error code definitions for public city node gateway:
7.4.6 Tezos
Tezos is an open-source platform for assets and applications backed by a global community of
validators, researchers, and builders. Tezos is designed to provide the safety and code
correctness required for assets and other high value use cases. Its native smart contract language,
Michelson, facilitates formal verification, a methodology commonly used in mission-critical
environments such as the aerospace, nuclear, and semiconductor industries.
The BSN city node gateway is adapted to the Tezos JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://tezos.gitlab.io/api/rpc.html
The following table shows additional error code definitions for public city node gateway:
7.4.7 IRISnet
Within the ecosystem of IRISnet, the core innovation is embodied in three aspects: integrate
the service-oriented infrastructure into the Cosmos network; integrate business services
provided by heterogeneous systems, including public chains, consortium chains, and existing
systems; the connectivity of services is realized through the blockchain Internet.
128
Blockchain-based Service Network User Manual
The BSN city node gateway is adapted to the IRISnet JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://www.irisnet.org/docs/endpoints/intro.html
The following table shows additional error code definitions for public city node gateway:
7.4.8 dfuse-eos
dfuse is a massively scalable open-source platform for searching and processing blockchain
data. It provides real-time, historical and fork-aware search engine (dfuse Search), transaction
push guarantees (dfuse Push Guarantee), transaction lifecycle (dfuse Lifecycle), historical state
services (dfuse State), and many more blockchain building blocks. dfuse empowers developers
with capabilities to build modern blockchain applications with fast, fluid interfaces that deliver
exceptional user experiences.
The current dfuse EOS mainnet access on BSN is available through dfuse Community Edition
hosted by EOS Nation. Try out the dfuse API features on the [GraphiQL playground]
(https://eos.dfuse.eosnation.io/graphiql).
If your needs exceed the Community Edition limits, please contact dfuse to set up an
[Enterprise plan] (https://dfuse.io/zh/pricing/?utm_source=BSN).
The BSN PCN gateway is equipped with sfuse's JSON RPC API and GraphQL, so developers
can issue EOSIO transaction requests to the node gateway via HTTP JSONrpc or GraphQL.
The following table shows additional error code definitions for public city node gateway:
7.4.9 ShareRing
129
Blockchain-based Service Network User Manual
The BSN city node gateway is adapted to the ShareRing JSON RPC API and WSS, so
developers can initiate transaction requests to the node gateway via HTTP JSON-RPC. For
detailed docking instructions please visit:
https://sharering.network/resources/ShareRing+API+Overview.pdf
The following table shows additional error code definitions for public city node gateway:
7.4.10 Algorand
Algorand built and developed the world’s first open, permissionless, pure proof-of-stake
blockchain protocol that, without forking, provides the necessary security, scalability, and
decentralization needed for today’s economy. With an award-winning team, Algorand enables
traditional finance and decentralized financial businesses to embrace blockchain for
decentralized applications.
The BSN city node gateway is adapted to the Algorand Rest API, so developers can initiate
transaction requests to the node gateway via Rest. Developers can also use Algorand SDK to
connect to BSN nodes for developing and deploying applications.
https://developer.algorand.org/docs/reference/sdks/
The following table shows additional error code definitions for public city node gateway:
7.4.11 BTY
130
Blockchain-based Service Network User Manual
BTY (Bityuan) is a simple, stable and scalable public chain network. It is developed using the
technology of Chain33 and is the world's first public chain project with a multi-chain
(parachain) architecture.
Multiple parachains can be developed on the BTY blockchain. The BTY’s main chain is
responsible for transaction settlement, and smart contracts and virtual machines are deprived
from the main chain and put on the parachain for independent executions, and multiple
parachains co-exist to improve computing efficiency. In addition, parachains can be
interconnected by the main chain.
At present, there are a number of application cases of parachain based on BTY public chain,
such as DeFi, C2C trading, royalty points, prepaid cards, games, real estate, commodities,
smart clearing, etc.
The BSN City Node Gateway is adapted to the BTY JSON RPC API, so developers can initiate
BTY transaction requests to the node gateway by means of JSON-RPC.
The following table shows additional error code definitions for public city node gateway:
131
Blockchain-based Service Network User Manual
Investors of Oasis Network include a16z, Accel, Polychain, Pantera, IOSG, etc.
To learn more information, please join the Oasis Community at t.me/oasisprotocolcommunity
and follow us on Twitter @oasisprotocol.
For more resources, please visit: https://docs.oasis.dev/general/
The BSN city node gateway is adapted to the Oasis Network REST API, so developers can
initiate transaction requests to the node gateway via HTTP REST. For detailed docking
instructions please visit: https://www.rosetta-api.org
7.4.13 Polkadot
Polkadot is a next-generation blockchain protocol that unites an entire network of purpose-built
blockchains, allowing them to operate seamlessly together at scale. Because Polkadot allows
any type of data to be sent between any type of blockchain, it unlocks a wide range of real-
world use cases. By bringing together the best features from multiple specialized blockchains,
Polkadot paves the way for new decentralized marketplaces to emerge, offering fairer ways to
access services through a variety of apps and providers. Polkadot’s design offers several
distinct advantages over existing and legacy networks, including heterogeneous sharding,
scalability, upgradeability, transparent governance and cross-chain composability.
The BSN city node gateway is adapted to the Polkadot JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit: https://polkadot.js.org/docs/substrate/rpc/#chain
The following table shows additional error code definitions for public city node gateway:
7.4.14 Casper
CasperLabs, the developer of the Casper Network, provides professional services and support
for organizations building on the Casper network. Guided by open-source principles,
CasperLabs is committed to supporting the next wave of blockchain adoption among
132
Blockchain-based Service Network User Manual
businesses and providing developers with a reliable and secure framework to build private,
public and hybrid blockchain applications. Its team possesses deep enterprise technology
experience, hailing from organizations including Google, Adobe, AWS, Dropbox and
Microsoft.
The BSN city node gateway is adapted to the Casper JSON RPC API, so developers can initiate
transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://docs.rs/casper-node/latest/casper_node/rpcs/index.html
The following table shows additional error code definitions for public city node gateway:
7.4.15 Findora
Findora’s mission is to build a decentralized financial network for issuing confidential assets
and smart contracts. Findora has created a system that achieves privacy-preserving
transparency. Its flexible technology can also be used by institutions to replace their current
infrastructure or deploy in the cloud – all interoperable with the public Findora network.
The BSN city node gateway is adapted to the Findora REST API, so developers can initiate
transaction requests to the node gateway via HTTP REST. For detailed docking instructions
please visit:
https://api.findora.org/
The following table shows additional error code definitions for public city node gateway:
7.4.16 Near
133
Blockchain-based Service Network User Manual
NEAR is a Proof-of-Stake Layer-1 public blockchain platform built with usability and
developer accessibility in mind. With a novel sharding mechanism called Nightshade, NEAR
can scale limitlessly and offers familiar user experiences just like the web today.
The BSN city node gateway is adapted to the Near JSON RPC API, so developers can initiate
transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://docs.near.org
The following table shows additional error code definitions for public city node gateway:
The BSN city node gateway is adapted to the Cypherium JSON RPC API, so developers can
initiate transaction requests to the node gateway via HTTP JSON-RPC.
The following table shows additional error code definitions for public city node gateway:
134
Blockchain-based Service Network User Manual
can adopt in their daily lives. Klaytn follows a consortium structure where leading global
companies of various industries actively participate and operate together. The key features
include fast response time, high efficiency, and a stable transaction fee structure, which makes
the platform ideal for operating large-scale user services. It also adopts a Hybrid Blockchain
Platform format that combines public and private blockchains to meet the needs of services
and businesses that target a large user base.
The BSN city node gateway is adapted to the Klaytn JSON RPC API, so developers can initiate
transaction requests to the node gateway via HTTP JSON-RPC. For detailed docking
instructions please visit:
https://refs.klaytnapi.com/en/node/latest
The following table shows additional error code definitions for public city node gateway:
135
Blockchain-based Service Network User Manual
8 Interchain Services
A cross-chain mechanism is the interoperability between two or more relatively independent
blockchains, and it enables the swap and transfer of data, asset and information. On the BSN,
every blockchain maintains its own transactions, consensus, and ledgers, carrying business data
and information of different DApps. The cross-chain mechanism realizes data sharing and
business collaboration among blockchains, and to break the silos between chains, allows data
to flow securely and reliably across multiple chains. The main functions of the cross-chain
system include: cross-chain registration management mechanism, cross-chain contract
functions, cross-chain transaction verification, cross-chain message routing protocol, cross-
chain transaction atomicity guarantee, etc.
The BSN Interchain Communications Hub (ICH) adopts the cross-chain protocol of
heterogeneous chains and the design of double-layer structure, using relay chains as cross-
chain coordinators, multiple heterogeneous chains as cross-chain transaction executors, and
acts as a relayer of cross-chain data. By solving validity, security, and transactional issues of
cross-chain data, a secure, easy-to-use and efficient cross-chain system is implemented:
Supports both isomorphic and heterogeneous chains.
Supports any information to cross the chains.
Very easy to access. Application chains do not need to do custom development adaptation,
just deploy one smart contract per chain.
Transactional support, supporting not only scenarios with the need for ultimate consistency
of transactions, but also scenarios with the need for strong consistency of transactions,
with support for any transaction, and scalable to any number of chains.
Cross-chain protocols are secure and reliable, based on cryptography and consensus
algorithms, and each application chain can verify the legitimacy of cross-chain
transactions on its own, thus ensuring the security of cross-chain interactions.
The BSN’s “Interchain Communications Hub” (ICH) is now commercially available and
integrates with Onchain's Poly Enterprise and Bianjie’s IRITA cross-chain solutions. It enables
cross-chain interoperability between standard permissioned chains, open permissioned chains
and public chains.
A demo version of ICH is also live on the BSN Testnet, integrating two interchain solutions
based on the relay chain mechanism: Poly Enterprise developed by Onchain and IRITA
developed by Bianjie AI. We welcome all developers to try out and provide feedback and
suggestions to us and we will continue to improve the interchain functionality.
136
Blockchain-based Service Network User Manual
For published permissioned services, publishers can open Interchain Services through the
Service Upgrade function:
On the home page, click Permissioned Services -> Published Services, click Service
Upgrade in the Action column to enter the service upgrade page.
In the Interchain Services section, select Yes to activate Interchain Services, and choose the
Interchain Service Protocol. Then, click Confirm to submit the service upgrade. After the
system review and approval, the Interchain Service is successfully opened.
137
Blockchain-based Service Network User Manual
Note: If you open Interchain Services only, you don't need to upload new chaincode package;
after opening the service, when calling across the chain, both source chain and target chain
need to communicate off the BSN about cross-chain parameters, methods and specifications.
Click Activate Interchain Services button to enter Select services page, click Activate
Interchain Services in the Action column.
The following steps can refer to Open the Interchain Service when upgrading the
permissioned service.
Note: For activated interchain services, users cannot change the interchain service protocols.
The protocol can only be changed by re-opening the interchain services.
138
Blockchain-based Service Network User Manual
Select the service to be checked, click View in the Action column, select Cross-chain
Information, users can check the chain ID, management contract address, management
contract name and cross-chain information.
On the Cross-chain Information page, click Details button to jump to Call Details page. Select
the parameter and click Query to retrieve the detailed cross-chain call information.
Go to List of cross-chain call details section, click Details button in Action column to enter
the Basic Information page, you can view the basic information of the cross-chain call details,
as shown in the figure:
139
Blockchain-based Service Network User Manual
On the home page, click Interchain Services, users can see a list of their activated interchain
services. Select the service which needs to be deactivated and click Deactivate button in
Action column.
Note: It takes a few minutes to deactivate the interchain service, please be patient.
On the home page, click Interchain Services, users can see a list of their activated interchain
services. Select the service which needs to be activated and click Activate button in Action
column.
140
Blockchain-based Service Network User Manual
141
Blockchain-based Service Network User Manual
142
Blockchain-based Service Network User Manual
An example of a specific cross-chain transaction call can be found in 7.2.2.3 Demo Contract
Example.
https://github.com/BSNDA/ICH/tree/main/sample/polychain/fabric-contract/online/hellopoly
/**
* @param _toChainId: The chain ID corresponding to the target chain being called in the
Poly network
143
Blockchain-based Service Network User Manual
* @return bool
**/
IEthCrossChainManagerProxy eccmp =
IEthCrossChainManagerProxy(managerProxyContract);
/**
144
Blockchain-based Service Network User Manual
* @return bool
**/
hearSomeThing = _somethingWoW;
return true;
}
Demo Contract Example
GitHub: https://github.com/BSNDA/ICH/tree/main/sample/polychain/eth_contracts/hellopoly
8.2.5 Interchain Services based on Neo Testnet
Application Contract Development Guide
The development of Neo application contract is based on its own business scenario. The main
implementation includes two parts: if the source chain initiates a cross-chain transaction, its
application contract needs to get outbound to access the target chain; if the target chain receives
a cross-chain transaction, its application contract needs to get inbound. Neo's chain ID in the
BSN Testnet is 4. This chain ID is registered in Poly Enterprise the configuration is applicable
to both BSN Production Environment and Testnet.
/// <summary>
/// This method is used to make cross-chain calls to other target chains (this method is
self-defining)
/// </summary>
/// <param name="msg">The cross-chain information that the target chain needs to
pass to apply the contract</param>
/// <returns></returns>
[DisplayName("say")]
145
Blockchain-based Service Network User Manual
// Event notification
HelloPoly.SayEvent(toChainId, toProxyHash);
return true;
/// <summary>
/// This method is used to make cross-chain calls to other target chains (this method is
self-defining)
/// </summary>
/// <returns></returns>
[DisplayName("hear")]
146
Blockchain-based Service Network User Manual
Storage.Put(fromProxyContract, inputBytes);
// Event notification
return true;
As the core of the entire cross-chain contract, Service Core is responsible for receiving a cross-
chain request from the application contract, the request result from the relayer, and return the
cross-chain call result, including the following functions:
Call Service: Function to make a cross-chain request. It is invoked by the application
contract by passing the interchain service name, input parameters, callback contract info,
etc. A successful invocation will return a unique request ID.
Set Response: Return the cross-chain invocation result called by relayer and write the result
147
Blockchain-based Service Network User Manual
to the application chain. If an application contract method needs to be called back during
service invocation, it needs to be called in this function.
Get Response: Query the cross-chain invocation result by request ID.
b. Target Core
TargetCore is the entrance of the target contract on the target chain, responsible for receiving
cross-chain requests from the cross-chain to the target chain, redirecting requests to the target
contract, and generating events containing the response message after getting the response,
including the following functions:
• Call Service: Call the function of the target contract, called by the provider, pass in the
requestID of the cross-chain request, target contract address, call parameters, and return the
call result after successful call.
2. Application Contract
Application contract is developed by the developer for the interchain services. In an application
contract, the developer can invoke the call service function of the cross-chain contract to make
a cross chain call. A callback function in the application contract also needs to be provided to
get the call result, otherwise developers will have to call the Get Response function in an
application contract to query the service invocation results.
3. Relayer
Relayer is a service that listens for the cross-chain request submitted to ICH by a source chain.
It is responsible for listening the call service function event, and submitting to the ICH.
4. Service Provider
Service provider, connects the HUB to the destination chain. It is a service that listens for the
cross-chain request from the ICH, invokes the destination chain, and returns the transaction
results to the ICH.
5. Interchain Service
The interchain service is developed by the service provider. It could be the smart contract
deployed on one blockchain for an application on another blockchain to call across the chain.
Support from the service provider is required to turn a service into an interchain service.
6. Interchain Communications Hub
As the core component of BSN's interchain service, the ICH is responsible for receiving cross
chain requests submitted by the source chain Relayer, verifying the transaction and initiating
the cross-chain transaction with the Service Provider of the destination chain. After the
transaction is complete, it is also responsible for obtaining the transaction result from the
Service Provider, verifying and returning the result to the source chain Relayer.
8.3.3 Interchain Services in BSN Testnet
In the BSN Testnet, we provide cross-chain calls between Fabric, FISCO BCOS and ETH
(Ropsten) , as well as enable the function of calling Chainlink services.
Before calling the service, users need to develop an application contract or use the sample
contract provided by the BSN to invoke it. The following are the parameters of the interchain
service deployed in the Testnet, according to which developers can initiate cross-chain calls.
ChainID of the Testnet
148
Blockchain-based Service Network User Manual
149
Blockchain-based Service Network User Manual
import (
"github.com/BSNDA/ICH/sample/irita/consumers/fabric/crosschaincode"
)
3. Call the crosschaincode.CallService method in the invoke function using the parameters of
the method as follows:
• stub: shim.ChaincodeStubInterface
• serviceName: the interchain service name to invoke, nft for ETH, and bcos-store
for FISCO BCOS
• input: the input object for interchain service
• callbackCC: callback chaincode name
• callbackFcn: callback chaincode function name
• timeout: timeout
The input parameter varies according to the interchain service and type passed in. In the
ETH service, the input structure is as follows:
type Input struct {
ABIEncoded string `json:"abi_encoded,omitempty"`
To string `json:"to"`
AmountToMint string `json:"amount_to_mint"`
MetaID string `json:"meta_id"`
SetPrice string `json:"set_price"`
IsForSale bool `json:"is_for_sale"`
}
In the FISCO BCOS service, the input structure is as follows:
type BcosInput struct {
Value string `json:"value"`
}
A unique request ID will be returned after successful invocation. Keep this value and use
it to determine the cross-chain results in the callback function.
4. Implement the callback interface:
After the cross chaincode receives the service response from Fabric Relayer, the callback
method name and callback chaincode name passed in will be called to return the service
response. The first parameter of the call returns a JSON-formatted string. Below is the
service response structure:
type ServiceResponse struct {
RequestId string `json:"requestID,omitempty"`
ErrMsg string `json:"errMsg,omitempty"`
Output string `json:"output,omitempty"`
IcRequestId string `json:"icRequestID,omitempty"`
}
Method crosschaincode.GetCallBackInfo() could be called to Serialize the value. The
requestID is unique and can be used to conduct the business processing. Output a JSON-
150
Blockchain-based Service Network User Manual
formatted string which is the return value of the crosschain response. Below is the input
data structure:
type InputData struct {
Header interface{} `json:"header"`
Body interface{} `json:"body"`
}
Parameter “Body” is the output object for the service. In ETH service, the input structure
is as follows:
type Output struct {
NftID string `json:"nft_id"`
}
In FISCO BCOS service, the output structure is as follows:
type BcosOutput struct {
Key string `json:"key"`
}
5. Package the chaincode
ICH.git, which is imported by the chaincode, needs to be packaged with the chaincode
together by govendor. If you haven’t installed govendor, you can install it as below:
Install govendor:
go get -u -v github.com/kardianos/govendor
Execute in the main method directory:
govendor init
govendor add -tree github.com/BSNDA/ICH/sample/irita/consumers/fabric/crosschaincode
After execution, the vendor folder will be generated. For the last step, compress the
project and vendor folder together, then upload and deploy it in BSN portal.
Application Contract Example
GitHub: https://github.com/BSNDA/ICH/tree/main/sample/irita/consumers/fabric/chaincode
8.3.3.2 Interchain Application Contract based on FISCO BCOS
The interchain consuming contracts based on iService with Solidity are applicable for the EVM
compatible application blockchain platform like Ethereum and FISCO BCOS.
Application Contracts Development Guide
IService Client: For convenience, the contract named iService Client is built to encapsulate the
interaction with the iService Consumer Proxy and handle logistics including event triggering,
request validation and status maintaining, which helps improve development efficiency.
The iService Client source code can be found in the Example Contract.
1. Import iService Client
To use the iService Client, import the corresponding contract path. For example:
import ServiceClient.sol
Note: You can directly use the iService Client code as a part of the consuming contract.
151
Blockchain-based Service Network User Manual
bytes32 _requestID,
serviceName,
requestInput,
timeout,
address(this),
this.callback.selector
);
152
Blockchain-based Service Network User Manual
Note: Developers need to retrieve information related to the service from the iService
Market Ex deployed on the application chain for the interchain service invocation, such
as the service name and schemas of the input and output.
4. NFT Service Consuming Contract Example
The NFT service is provided by the NFT contract on the Ethereum Ropsten to create NFT
assets.
The definition of the NFT service is as follows:
Service name: nft
Service Input JSON Schema:
{
"type": "object",
"properties": {
"to": {
"description": "address to which the NFT will be minted",
"type": "string"
},
"amount_to_mint": {
"description": "amount of the NFT to be minted",
"type": "string"
},
"meta_id": {
"description": "meta id",
"type": "string"
},
"set_price": {
"description": "price in Ethereum Wei",
"type": "string"
},
"is_for_sale": {
"description": "whether or not the minted NFT is for sale",
"type": "boolean"
}
}
}
153
Blockchain-based Service Network User Manual
"type": "string"
}
}
}
Developers can develop contracts on application chains to implement to mint NFT
assets across chains.
Application Contract Example
GitHub:
https://github.com/BSNDA/ICH/tree/main/sample/irita/consumers/fiscobcos/NFTServiceCon
sumer
8.3.4 Interchain Services based on Hyperledger Fabric
Application Contract Development Guide
1. Preparation:
Run the code below to obtain the BSN interchain consuming contract help package
(ICH.git). Currently, only the GO language version is supported but more versions will be
added later.
cd $GOPATH
mkdir -p src/github.com/BSNDA && cd src/github.com/BSNDA
git clone https://github.com/BSNDA/ICH.git
2. Initiate the interchain service request
After creating the Fabric chain code struct and invoke function, import below package:
import (
"github.com/BSNDA/ICH/sample/irita/consumers/fabric/crosschaincode"
)
Call the crosschaincode.CallService method in the invoke function using the parameters of
the method as follows:
• stub: shim.ChaincodeStubInterface
• serviceName: the interchain service name of permissioned chain is “cross_service”
• input: the input object for interchain service
• callbackCC: callback chaincode name
• callbackFcn: callback chaincode function name
• timeout: timeout
The input parameter varies according to the interchain service and type passed in. In the
Fabric service, the input structure is as follows:
type Input struct {
ChainId uint64 `json:"chainId"`
ChainCode string `json:"chainCode"`
FunType string `json:"funType"`
Args []string `json:"args"`
}
In the FISCO BCOS service, the input structure is as follows:
154
Blockchain-based Service Network User Manual
}
In FISCO BCOS service, the output structure is as follows:
type BcosOutput struct {
Result string `json:"result,omitempty"`
Status bool `json:"status,omitempty"`
TxHash string `json:"tx_hash,omitempty"`
155
Blockchain-based Service Network User Manual
}
4. Pack the chaincode
ICH.git, which is imported by the chaincode, needs to be packaged with the chaincode
together by govendor. If you haven’t installed govendor, you can install it as below:
Install govendor:
go get -u -v github.com/kardianos/govendor
Execute in the main method directory:
govendor init
govendor add -tree github.com/BSNDA/ICH/sample/irita/consumers/fabric/crosschaincode
After the execution, the vendor folder will be generated. For the last step, compress the
project and vendor folder together, then upload and deploy it in the BSN portal.
Application Contract Example
GitHub:
https://github.com/BSNDA/ICH/tree/bsnirita/sample/irita/consumers/fabric/chaincode
Note: You can directly use the iService Client code as a part of the consuming contract.
2. Inherit iService Client
contract <consuming-contract-name> is iServiceClient {
156
Blockchain-based Service Network User Manual
bytes32 _requestID,
serviceName,
requestInput,
157
Blockchain-based Service Network User Manual
timeout,
address(this),
this.callback.selector
);
Note: Developers need to retrieve information related to the service from the iService
Market Ex deployed on the application chain for the interchain service invocation, such
as the service name and schemas of the input and output.
4. Fabric cross-chain call example
Service name: cross_service
Service Input JSON Schema:
{
ChainId uint64 `json:"chainId"`
ChainCode string `json:"chainCode"`
FunType string `json:"funType"`
Args []string `json:"args"`
{
Result string `json:"result,omitempty"`
Status bool `json:"status,omitempty"`
158
Blockchain-based Service Network User Manual
159
Blockchain-based Service Network User Manual
9 Oracle Services
Blockchain is a deterministic and closed environment. Transactions generated by smart
contracts in the blockchain also need deterministic results, so the host virtual machine (VM) of
smart contracts is prohibited to include uncertain external calls when building transactions.
This processing mechanism leads to the inability to actively access external data within the
blockchain. To solve this problem, we integrate the oracle service. The oracle service is a bridge
between the blockchain and the real world, connecting the blockchain to the real world by
feeding real-world data to the blockchain and providing smart contracts with connectivity to
the external world.
The main functions of BSNs services include: management mechanism of oracle management
contract, oracle application contract function, and oracle off-BSN service.
BSN oracle services will integrate centralized and decentralized mechanisms for blockchain to
acquire off-chain data, and developers can choose different forms of oracle services to meet
their demands for off-chain data access.
At present, BSN oracle services have been launched on the BSN Testnet, which integrates the
the Chainlink oracle service supported by IRITA Hub built by IRISnet’s core development
team Bianjie. We will continue to improve the functions and integrate more oracle services.
In the BSN Testnet, users can use the IRITA-based cross-chain architecture to invoke the
Chainlink oracle services, and the services currently available for trial in the Testnet is
eth_usdt_price service.
160
Blockchain-based Service Network User Manual
(1) Appchain in the BSN triggers cross-chain transaction request, and the user contract invokes
management contract.
(3) Relayer sends the data request to IRITA Hub in the Interchain Communications Hub.
(7) Chainlink Oracle returns the request result to BSN Oracle Service.
(8) Provider receives the response to the cross-chain request from the corresponding
chain/service.
(11) Data is sent back to the BSN appchain that originally initiated the request.
161
Blockchain-based Service Network User Manual
In the BSN, calling the Chainlink service through the IRITA interchain hub is just like calling
the cross-chain service, the CallService method is called in the user's application contract.
Currently, the Testnet provides eth_usdt_price_test service. The service call is the same as the
cross-chain call, please refer to chapter 8.3 "Interchain Services based on IRITA".
When calling the Chainlink service, the target contract address is:
iaa15s9sulrnmctzluc42g7lkxh92ardkc9xccxsy9
{"service_name":"eth-usdt-
price","providers":["iaa16eu2jvgpa5ek9mn2tn985jlm89e6dch92qwj09"],"input":"{\"header\"
:{},\"body\":{}}","timeout":100,"service_fee_cap":"1000000upoint"}
{"last": "1000"}
Note: Since the name of the called Chainlink oracle service is already identified in the
parameters of the cross-chain service call, the input parameter to call the Chainlink service is
empty.
The specific example contracts can be found in the chapter 8.3.4 "Interchain Services based on
Hyperledger Fabric" and chapter 8.3.5 "Interchain Services based on FISCO BCOS" for the
description of Fabric and the FISCO BCOS framework for invoking cross-chain contracts.
//SPDX-License-Identifier: SimPL-2.0
/**
*/
interface iServiceInterface {
/**
162
Blockchain-based Service Network User Manual
*/
function sendRequest(
address _callbackAddress,
bytes4 _callbackFunction
/**
*/
function setResponse(
bytes32 _requestID,
/*
*/
contract iServiceClient {
163
Blockchain-based Service Network User Manual
// request
struct Request {
/*
*/
/*
*/
require(
requests[_requestID].sent,
);
require(
!requests[_requestID].responded,
);
_;
/**
164
Blockchain-based Service Network User Manual
*/
function sendIServiceRequest(
address _callbackAddress,
bytes4 _callbackFunction
requestID = iServiceCore.sendRequest(
_endpointInfo,
_method,
_callData,
address(this),
this.onResponse.selector
);
_callbackAddress,
_callbackFunction,
true,
false
);
requests[requestID] = request;
emit RequestSent(requestID);
return requestID;
/*
165
Blockchain-based Service Network User Manual
*/
external
validRequest(_requestID)
);
if (!success) revert();
/**
*/
require(
_iServiceCore != address(0),
);
iServiceCore = iServiceInterface(_iServiceCore);
/*
*/
'{"dest_chain_id":"10227431719070003","dest_chain_type":"opb","endpoint_address":"iaa15s9sulrnm
ctzluc42g7lkxh92ardkc9xccxsy9","endpoint_type":"service"}';
166
Blockchain-based Service Network User Manual
/*
* @notice Constructor
*/
setIServiceCore(_iServiceCore);
/*
*/
string
price","providers":["iaa16eu2jvgpa5ek9mn2tn985jlm89e6dch92qwj09"],"input":"
{\\"header\\":{},\\"body\\":
{}}","timeout":100,"service_fee_cap":"1000000upoint"}';
callData = bytes(callDataJsonStr);
sendIServiceRequest(
endpointInfo,
"service",
callData,
address(this),
this.onHello.selector
);
/*
167
Blockchain-based Service Network User Manual
*/
external
validRequest(_requestID)
requests[_requestID].responded = true;
result = _output;
2. Service call
Open your browser and login to the Chainlink Operator Dashboard to view the result of the
oracle service invocation in the interface.
⚫ Link: http://47.100.192.234:6688/
⚫ Account number: test@gmail.com
⚫ Password: chainlinkPASSWORD123
168
Blockchain-based Service Network User Manual
The result returned by the cross-chain call can be viewed through the result method of the
application contract.
169
Blockchain-based Service Network User Manual
10 IDE Services
10.1Overview
An integrated development environment (IDE) is a software application that provides
comprehensive facilities to computer programmers for software development. It enhances the
development experience and efficiency by integrating tools such as compiler, editor, interpreter,
debugger, project manager, etc.
BSN IDE Services customize and integrate the third-party IDEs corresponding to the
frameworks adapted in BSN to form a development tool suite. When users create, publish and
upgrade DApp services in the BSN portal, if the framework used in the current DApp service
has already integrated with the IDE, they can create and modify smart contracts by calling the
IDE website with one click from the DApp service page. After finishing programming,
developers can debug the code and deploy the smart contract in the BSN production
environment or BSN Testnet. Developers do not need to install their own development tools
and set up debugging environment, all edited smart contract packages can be synchronized and
saved in the BSN portal and IDE.
Currently, the BSN International portal provides IDE services for permissioned frameworks
including Hyperledger Fabric and FISCO BCOS, as well as public chains including Ethereum,
Algorand and Nervos.
This iteration of IDE services is only available on the web. In the future, BSN will continue to
integrate more frameworks and launch the BSN IDE client version.
10.2Access Instructions
Users can access to the IDE from BSN portal, or directly log in to the IDE web page with BSN
username and password.
If users jump from BSN portal to the IDE, the chaincode package will be automatically
synchronized, and after IDE finishes the operation of chaincode package and jumps back to the
portal, the chaincode package will be automatically synchronized to the corresponding service
in the portal.
BSN's IDE is mainly applicable to the following services: service publication of permissioned
chains, service editing and upgrading of permissioned chains, permissionless services and BSN
testnet services.
170
Blockchain-based Service Network User Manual
2. Choose the platform type, click “Confirm” button to jump to the IDE web page;
3. Create, edit and deploy the chaincode package in the IDE, and select “Create a new service”;
⚫ Create chaincode package:
Go to IDE, and click “New Project” button
When creating the chaincode package, the IDE supports to import the chaincode
package from BSN portal, or developer can create from template or upload from local
disk drive.
If “Create Type” is selected as “Upload from local”, developer should input chaincode
name, upload the chaincode package, and click “Create” button. Note that the file in the
chaincode package cannot contain Chinese characters.
171
Blockchain-based Service Network User Manual
If “Create Type” is selected as “Import from BSN”, developer should select the network
type, framework and chaincode package, and then click “Create” button to finish
creating the project.
172
Blockchain-based Service Network User Manual
173
Blockchain-based Service Network User Manual
4. Jump back to the BSN portal, “Create a New Service” page, and continue the following
process to publish the service. The chaincode package now has been synchronized to the
portal.
2. Select the chaincode package to be edited, and click on “Online IDE” button to jump to the
IDE web page.
174
Blockchain-based Service Network User Manual
5. Navigate to the BSN portal and continue the following service upgrade process. In the
“Upload chaincode package” section, click on “Select chaincode package from IDE” button
to select the chaincode package from the IDE and replace the current one.
1. Log in to the BSN portal, “Permissionless Services”, select the public city node and buy a
plan and create a project (for example on Ethereum-Mainnet);
175
Blockchain-based Service Network User Manual
2. On the project list, click on “Online IDE” button in the created project to jump to the IDE;
3. Create, edit, test and deploy the chaincode package in the IDE;
⚫ Chaincode package creation:
Go to IDE, and click “New” button.
On “Create a New Project” page, input the project name, select the template and click
“Create Project” button to create the chaincode package.
176
Blockchain-based Service Network User Manual
177
Blockchain-based Service Network User Manual
4. Chaincode package deployment. Developers can select the access information of the
project in the BSN portal.
10.3My IDE
Login to the BSN portal and go to home page, click 【IDE Services】, and enter the service
inquiry page.
BSN International portal supports developers to view the edited chaincode packages in IDE
service query page, developers can query by framework name or service name.
178
Blockchain-based Service Network User Manual
11 DID Services
11.1Overview
With blockchain technology as the cornerstone and W3C DID as the specification, BSN DID
Services achieve decentralized on-chain mapping of real entity, thus achieving the ability to
provide digital identity and digital credential interaction for individuals/organizations.
Roles
In the DID ecosystem, there are three roles: User, Issuer and Verifier.
User: Any individual/organization/entity that has a digital identity on the chain. Any entity
object can create and manage its DID through the developer’s project.
Issuer: The individual or organization that can issue the digital credentials For example, if
a university can issue a digital diploma to a student, then the university is an issuer.
Verifier: Also known as a business party, is an individual or organization that uses digital
credentials. After being authorized by the user, the verifier can verify the identity of the
user or their digital credentials. For example, when a company hires someone, it needs to
verify his college diploma, then the company is a verifier.
Components
The DID system consists of three components: SDK, Service and Smart Contract. The SDK
can be integrated in the developer’s project; Service handles the business logic and connects
the private data storage area (Identity Hub) to the chain node; the smart contract is deployed
on the chain, and the methods in the contract is called by the Service.
179
Blockchain-based Service Network User Manual
⚫ Deployed on the BSN, the DID Service builds a decentralized digital identity management
system, which facilitates autonomous participation and affirmative collaboration among
users, issuers and verifiers.
⚫ Provide mechanisms for issuance, authorization, verification and revocation of user data
credentials.
⚫ Provide a private data storage area (Identity Hub) where credentials are fully controlled by
users, and is stored and transmitted in encryption.
⚫ Provide unified access to API services and SDKs, integrate object encapsulation, signature,
verification and other methods for easy docking by developers.
2. Public parameters
180
Blockchain-based Service Network User Manual
1) Generate two public and private key pairs through the elliptic curve algorithm Secp256k1.
2) Save the private key and specify the primary and recovery public keys to assemble the Base
DID Document, the contents of which are shown below:
{
"@context":"https://w3id.org/did/v1",
"authentication":
{
"type":"Secp256k1",
"publicKey":
"28986472722394106073871327423452879123214061743224210681401278929598807211
14000127450753032422192379586544768083674234896333734351022988066996849973
5858"
}
"recovery":
{
"type":"Secp256k1",
"publicKey":
"92519711680429159415515746419877215039845427616418520648539645411813788327
46959340151297908312616596971625573967556676367696067937171601766581709843
378481"
}
}
{
"did":"did:bsn:3wxYHXwAm57grc9JUr2zrPHt9HC",
"version":1,
"created":"2021-05-20T16:02:20Z",
"updated":"2021-05-20T16:02:20Z",
"authentication":
{
"type":"Secp256k1",
"publicKey":
"28986472722394106073871327423452879123214061743224210681401278929598807211
14000127450753032422192379586544768083674234896333734351022988066996849973
181
Blockchain-based Service Network User Manual
5858"
}
"recovery":
{
"type":"Secp256k1",
"publicKey":
"92519711680429159415515746419877215039845427616418520648539645411813788327
46959340151297908312616596971625573967556676367696067937171601766581709843
378481"
}
}
5) Use the primary private key to sign the DID Document content with Secp256k1, and
finally form the DID Document with the signature attribute, as following:
{
"did":"did:bsn:3wxYHXwAm57grc9JUr2zrPHt9HC",
"version": 1,
"created":"2021-05-20T16:02:20Z",
"updated":"2021-05-20T16:02:20Z",
"authentication":
{
"type":"Secp256k1",
"publicKey":
"28986472722394106073871327423452879123214061743224210681401278929598807211
14000127450753032422192379586544768083674234896333734351022988066996849973
5858"
}
"recovery":
{
"type":"Secp256k1",
"publicKey":
"92519711680429159415515746419877215039845427616418520648539645411813788327
46959340151297908312616596971625573967556676367696067937171601766581709843
378481"
}
"proof":
{
"type":"Secp256k1",
"creator":"did:bsn:3wxYHXwAm57grc9JUr2zrPHt9HC",
"signatureValue":
"zD5nt+P/Ga/CRG2hJU/SMRXy210CLdvATsxQdPxTEy9Mc9Y0OSFpE3Yu5k2+OjQKV
Otu5of9VFbgO3Zljw/vQxs="
}
}
182
Blockchain-based Service Network User Manual
Verify the content format and signature value of the offline generated DID
Description
Document.
Interface request parameter
No. Parameter Type Required Description
1 VerifyDocumentReq Y Wrapper class
VerifyDocumentReq
1 didDoc DidDocument Y DID Document
DidDocument
1 did String Y DID
2 version String Y Version
3 created String Y Created date
4 updated String Y Updated date
5 authentication PublicKey Y Primary public key
6 recovery PublicKey Y Recovery public key
7 proof Proof Y Signature
PublicKey
1 publicKey String Y Public key
2 type String Y Algorithm type
Proof
DIDs involved in the calculation
1 creator String Y
of signature values
2 type String Y Algorithm type
3 signatureValue String Y Signature value
Interface response parameter
No. Parameter Type Description
1 Boolean Return true if success, return false if failed
183
Blockchain-based Service Network User Manual
184
Blockchain-based Service Network User Manual
185
Blockchain-based Service Network User Manual
11.2.2 Issuer
The issuer and user are two roles, and the following APIs are the pre-constraints for issuing
credentials. The process of changing the DID user to the issuer does not change the DID
Identifier or DID Document, but only the status.
To issue a credential, a DID user needs to register as an issuer and then define a template for
registering the credential they want to issue. The credential template will be stored on the chain
and everyone can query.
186
Blockchain-based Service Network User Manual
187
Blockchain-based Service Network User Manual
188
Blockchain-based Service Network User Manual
Proof
DID involved in the calculation of the
1 creator String
Signature value
2 type String Algorithm type
3 signatureValue String Signature value
189
Blockchain-based Service Network User Manual
11.2.3 Credential
The credential is generated based on the credential template. The application of the credential
is made by the user, and then the issuer issues the credential. The credential issuance process
is generally as follows:
DID user fills the DID user initiate Issuer issues the
DID user queries the
attributes of the the issuance credential to the
credential template application
credential template user
Once the user has the credentials issued by the issuer, he/she can present them to the verifier
for further use.
190
Blockchain-based Service Network User Manual
191
Blockchain-based Service Network User Manual
192
Blockchain-based Service Network User Manual
193
Blockchain-based Service Network User Manual
into the Hub, which verifies the identity of visitors while the data is encrypted during
transmission and storage, leaving users in full control of access to their own data.
194
Blockchain-based Service Network User Manual
Store the resource to the Hub. If the user stores it himself, the uid and the
ownerUid should be the same. At this time, there is no need to create permissions
Description to call directly; if the issuer stores it for the user after issuing the credentials, the
uid should be the issuer, and the ownerUid should be the user. At this time, the
user must have created “WRITE” permissions for it, otherwise the storage will fail.
Interface request parameter
No. Parameter Type Required Description
1 SaveResourceReq Y Wrapper class
SaveResourceReq
1 uid String Y ID in the Hub
2 content String Y Resource information
The path of the resource
storage. Null when it is user
3 url String N self-storage; required when
the issuer stores it for the
user
4 ownerUid String Y Resource owner
WRITE means add;
5 grant String Y
UPDATE means update
6 key String Y Key
7 sign String Y Signature
Interface response parameter
No. Parameter Type Description
1 SaveResourceResp Wrapper class
SaveResourceResp
1 url String The path of the stored resource
Null when the issuer stores it for users; if it is the
user self-storage, returns the KeyA encrypted by
the user's Public key, and the user's private key
2 encryptKey String
decrypts KeyA to derive the plaintext Key. The
resource stored in the Hub is encrypted by Key
with AES-ECB algorithm.
195
Blockchain-based Service Network User Manual
196
Blockchain-based Service Network User Manual
READ/UPDATE permission
is required
7 sign String Y Signature
Interface response parameter
No. Parameter Type Description
1 AddPermissionResult Response data
AddPermissionResult
1 url String The path of the stored resource.
Ciphertext key to encrypt the resource
2 Key String (encrypted using the authorized public
key)
197
Blockchain-based Service Network User Manual
198
Blockchain-based Service Network User Manual
GrantPermissionInfo
The path of the resource
1 url String
storage.
Authorization type.
2 grant String READ: Read; WRITE:
Add; UPDATE: Update
3 status Integer 0: deleted; 1: not deleted
Time to create
4 createTime Date
authorization
Accessed time. Null if not
5 readTime Date
accessed.
0: accessed; 1: not
6 flag Integer
accessed.
7 ownerUid String ID in the Hub
8 OwnerKey String Ciphertext key
9 key String Owner’s key
199
Blockchain-based Service Network User Manual
Ciphertext resource
7 content String
content
200
Blockchain-based Service Network User Manual
201
Blockchain-based Service Network User Manual
1082 The DID Document created time does not match the one on-chain
1083 The DID Document recovery key does not match the one on-chain
1084 Failed to add DID Document to the chain
1085 Failed to create the key pair
1086 Failed to calculate the DID
1087 Failed to calculate the DID Document signature
1088 Failed to create the DID Document
1090 The mnemonic is empty
1337 Failed to encrypt the key
1338 Failed to sign the data
Identity Hub
1303 Private key is empty
1304 Private key format is invalid
1305 Public key is empty
1306 Public key format is invalid
1307 Public key and private key do not match
1309 The content is empty
1310 The URL is empty
1321 The URL of the Identity Hub cannot be empty
1322 The public key of the Identity Hub cannot be empty
1327 Failed to send the request
1328 The format of the grant is invalid
1329 Grant cannot be empty
1335 Resource does not exist
1336 The key is empty
1337 Failed to encrypt the key
1338 Failed to sign the data
1341 Failed to delete permission
1342 Failed to query permission
1343 Grant is empty
1344 Failed to check permission
1347 Failed to query publicKey
1350 Config file does not exist
1351 The public key is empty
1352 You cannot add permissions to yourself
1354 Illegal flag
1361 The user ID is empty
1362 The granted user ID is empty
1363 The public key of the granted user is empty
1364 Failed to generate the user ID
202
Blockchain-based Service Network User Manual
203
Blockchain-based Service Network User Manual
11.4 SDK
BSN provides a Java version SDK, which implements signature, verification, communication
and other methods, so Java developers can quickly make API calls through the SDK.
1. Steps to Use
1) Download the SDK source code and compile and package it as a jar named did-sdk-
1.0.jar;
2) Add the did-sdk-1.0.jar to the classpath directory of the project project;
3) Create an instance of DidClient:
DidClient didClient = new DidClient(URL,PROJECTID,TOKEN);
4) Call the method in the SDK, as follows:
DidDataWrapper didData = didClient.createDid(true);
1. Specifications
❑ Timestamp
The format of the time is a string in the form of yyyy-MM-dd HH:mm:ss, for example:
2021-05-25 12:30:59 means May 25, 2021 at 12:30:59.
❑ Exception
A runtime exception “RuntimeException" is thrown when there is a runtime error.
2. Function Description
204
Blockchain-based Service Network User Manual
The methods in the SDK can be divided into four categories according to their functional
properties: DID, issuer, credential and privacy area, and each method is described below:
11.4.1 DID
11.4.1.1 Generate Private and Public Keys by Mnemonics
The user can customize mnemonics and call this function to generate a pair of public-private
keys for the k1 algorithm offline. As long as mnemonics are the same, the generated public and
private keys must be the same for each call.
205
Blockchain-based Service Network User Manual
DocumentInfo
206
Blockchain-based Service Network User Manual
207
Blockchain-based Service Network User Manual
anyone can query the corresponding DID Document from the chain by the DID. It
can be used to verify the DID and obtain the DID public key.
Request Parameters
No. Parameter Type Required Description
1 did String Y DID
Response Parameters
No. Parameter Type Required Description
1 didDocument DidDocument Y DID Document
DidDocument
No. Parameter Type Required Description
1 did String Y DID
2 version String Y Version
3 created String Y Created date
4 updated String Y Updated date
5 authentication PublicKey Y Primary public key
6 recovery PublicKey Y Recovery public key
7 proof Proof Y Signature
PublicKey
1 type String Y Algorithm type
2 publicKey String Y Public key
Proof
1 type String Y Algorithm type
2 creator String Y DID
3 signatureValue String Y Signature value
208
Blockchain-based Service Network User Manual
updated, the user's DID Document will also be updated, but the DID remains the
same. If the user fills in the primary public-private keys, the primary public keys in
the DID Document is updated and the signature is recalculated using the filled-in
primary public key; otherwise, a new pair of primary public private keys is
automatically generated and the primary public key and signature calculation of the
DID Document are updated. Note: If the issuer updates the key, all the previously
issued credentials will not pass the signature verification (if the issuer records the
master public key of the credential in the business system, it can transmit the old
master public key information to the user, then it can also pass the credential
verification).
Request Parameters
No. Parameter Type Required Description
1 ResetDidAuth Y
ResetDidAuth
1 did String Y DID
2 primaryKeyPair KeyPair N Primary public and private key
3 recoveryKey KeyPair Y Recovery public and private key
KeyPair
1 privateKey String Y Private Key
2 publicKey String Y Public Key
3 type String Y Algorithm type
Response Parameters
No. Parameter Type Required Description
1 KeyPair Y New public and private key pair
KeyPair
No. Parameter Type Required Description
1 privateKey String Y Private key
2 publicKey String Y Public key
3 type String Y Algorithm type
11.4.2 Issuer
11.4.2.1 Register Issuer
Function name registerAuthIssuer(RegisterAuthorityIssuer register)
The DID user becomes the issuer, and the issuer information is uploaded to the chain
Description
if the registration is successful.
Request Parameters
No. Parameter Type Required Description
1 RegisterAuthorityIssuer Y
RegisterAuthorityIssuer
1 privateKey String Y Private key
2 did String Y DID
3 name String Y Issuer’s name
Response Parameters
209
Blockchain-based Service Network User Manual
210
Blockchain-based Service Network User Manual
Map<String, Y
3 cptJsonSchema JsonSchema of credential template
JsonSchema>
4 title String Y Title
5 description String Y Description
6 type String Y Credential Type, fill in Proof
7 cptId Long Y Credential template ID
JsonSchema
1 type String Y Field type
2 description String Y Field description
3 required Boolean Y true: required; false: optional
Response Parameters
No. Parameter Type Required Description
Registration result, basic information of
1 CptBaseInfo Y
credential template
CptBaseInfo
No. Parameter Type Required Description
1 cptId Long Y Credential template ID
2 cptVersion Integer Y Credential template Version
211
Blockchain-based Service Network User Manual
212
Blockchain-based Service Network User Manual
213
Blockchain-based Service Network User Manual
11.4.3 Credential
11.4.3.1 Create Credential
Function name createCredential(CreateCredential createCredential)
The attribute values defined in the credential template are provided by the issuer for
the DID user to obtain on the front page. The issuer issues the credentials for the
Description
DID user through this interface. If there are more Claim parameters than defined in
the credential template, the server side will discard them.
Request Parameters
No. Parameter Type Required Description
1 CreateCredential Y
CreateCredential
1 cptId Long Y Credential template ID
Y DID of the credential
2 issuerDid String
template issuer
Y DID of the user who
3 userDid String
created the credentials
Y Credential expiration
date. Should be greater
4 expirationDate String
than today. In the form of
yyyy-mm-dd
Y Content of the credential.
Map<String, The claim data needs to
5 claim
Object> correspond to the format
of the credential template
Y Credential type, input
6 type String
Proof
7 privateKey String Y Private key
Brief description of the
credential. The default
8 shortDesc String N
value is the credential
template title.
Detailed description of
9 longDesc String N
the credential
Response Parameters
No. Parameter Type Required Description
Creation result,
1 CredentialWrapper Y
Credential information
CredentialWrapper
No. Parameter Type Required Description
1 context String Y Version
2 id String Y Credential ID
3 type String Y Credential type, Proof
214
Blockchain-based Service Network User Manual
215
Blockchain-based Service Network User Manual
216
Blockchain-based Service Network User Manual
217
Blockchain-based Service Network User Manual
RegisterHubResult
1 success Boolean Return true if success, return false if failure
2 uid String ID in the Hub
3 message String Result description
218
Blockchain-based Service Network User Manual
Response Parameters
No. Parameter Type Required Description
1 QueryResourceResp Y Query result
QueryResourceResp
No. Parameter Type Required Description
1 content String Y Ciphertext resource content
2 key String Y Ciphertext key
219
Blockchain-based Service Network User Manual
Response Parameters
No. Parameter Type Required Description
1 CreatePermissionResp Y Creation result
CreatePermissionResp
No. Parameter Type Required Description
1 url String Y The path of the stored resource.
2 key String Y Ciphertext key
220
Blockchain-based Service Network User Manual
221
Blockchain-based Service Network User Manual
222
Blockchain-based Service Network User Manual
223
Blockchain-based Service Network User Manual
12 Account Management
In the My Account page, the user can view details of their card and transactions they performed
on the network. To work with My Account, follow these steps:
1. In the User Center menu, click the dropdown to reveal the list, in the menu list, click My
Account to display the page.
2. To update the user Card Information, click the Update card information to display the
My Credit Card page. The user will be redirected to the Stripe website. The BSN portal
can never see and does not store credit card information.
3. Update the card details as needed and click Update.
5. In the Bill list, under the Status and Action columns, the user can perform certain actions
including Pay and Details on each bill. To pay a bill, click Pay and to View a bill, click
Details.
224
Blockchain-based Service Network User Manual
13 Online Documentation
White Papers
Name Version Update Details
BSN Introduction White paper V1.05 February 5th,2020 PDF
BSN Technical White Paper V1.0.0 April 25th,2020 PDF
Site Documents
Name Version Update Details
User Manual 1.8.1 April 24th,2022 Online PDF
Fabric Examples 1.0.1 April 24th,2020 Github
FISCO BCOS Examples 1.0.1 April 24th,2020 Github
SDK Examples 1.0.1 April 24th,2020 Github
Permissioned Frameworks
Name Official Website Details
Hyperledger Fabric https://www.hyperledger.org/ Github Documentation
FISCO BCOS http://fisco-bcos.org/ Github Documentation
ConsenSys Quorum https://consensys.net/quorum/ Github Documentation
Hyperledger Besu https://www.hyperledger.org/use/besu Github Documentation
Public Chains
Name Official Website Details
Nervos https://www.nervos.org/ Github Documentation
NEO https://neo.org/ Github Documentation
ETH https://ethereum.org/ Github Documentation
Tezos https://tezos.com/ Github Documentation
EOS https://eos.io/ Github Documentation
IRISNET https://www.irisnet.org/ Github Documentation
dfuse-eos https://www.dfuse.io/en/home/?utm_source=BSN Github Documentation
225
Blockchain-based Service Network User Manual
226
Blockchain-based Service Network User Manual
14 Contact Us
If you have any questions or find any errors in this manual, please contact us:
Email: support@bsnbase.com
227