5.4.2.2 Hyperledger Fabric preset smart contract package

A preset chaincode package (Golang) is provided to BSN developers which contains basic functions such as add, delete, edit, and query. New DApp developers can learn from this package about Fabric chaincode programming and further extend the functions if needed. The chaincode in this package supports data types such as string, integer, float point, and sets (map, list), etc.

Please click this link to download:

Fabric 1.4.3:

https://github.com/BSNDA/FabricBaseChaincode

Fabric 2.3.2:

https://github.com/BSNDA/FabricBaseChaincode/tree/master/chaincode/go/bsnBaseChaincode

DApp publishers can also select the preset chaincode package directly from the DApp publishing page on the BSN portal.

The preset Chaincode package functions are as follows:

1. Add data (set)

Input parameter description:

baseKey: a unique primary key identifier of data

baseValue: stored data information

Example: {"baseKey": "str","baseValue": "this is string"}

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.

2. Update data (update)

Input parameter description:

baseKey: a unique primary key identifier of data

baseValue: stored data information

Example: {"baseKey": "str","baseValue": "this is string"}

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.

Note: this method is only applicable to Fabric 1.4.3 preset chaincode package.

3. Delete data (delete)

Input parameter description

baseKey: a unique primary key identifier of data

Example: "str"

Of which, the baseKey value cannot be blank and must exist, else it cannot be deleted.

4. Get data (get)

Input parameter description

baseKey: a unique primary key identifier of data

Example: "str"

Of which, the baseKey value cannot be blank and must exist, else it cannot be retrieved.

Note: “get” method is only applicable to Fabric 1.4.3 preset chaincode package while “query” method is only applicable to Fabric 2.3.2 preset chaincode package.

5. Get historic ledger data (getHistory/history)

Input parameter description

baseKey: a unique primary key identifier of data

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.

© 2019-2023 Red Date (Hong Kong) Technology Limited. all right reserved,powered by GitbookFile Modify: 2023-02-16 12:22:01

results matching ""

    No results matching ""

    results matching ""

      No results matching ""