fabric-samples/asset-transfer-private-data
Mark S. Lewis 63cc77bdc3
Avoid usage of deprecated ioutil Go package (#843)
* Refactor Go files
1. replace deprecated ioutil functions (ioutil is deprecated since Go 1.16)
2. fix variable names that collide with imported package name
3. fix typos

Also update Go version specified by Go modules to ensure a Go version is used in which ioutil is deprecated and replacement functions are available in os and io packages.

Signed-off-by: Tommy TIAN <xtianae@connect.ust.hk>
Co-authored-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

* Specify go 1.18 instead of go 1.19 in go.mod files

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Signed-off-by: Tommy TIAN <xtianae@connect.ust.hk>
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
Co-authored-by: Tommy TIAN <xtianae@connect.ust.hk>
2022-10-25 07:04:39 -04:00
..
application-gateway-typescript Update samples to use fabric-gateway v1.1.1 (#842) 2022-10-20 17:43:55 +01:00
application-javascript Update Javascript and Typescript Deps (#403) 2021-01-13 12:19:31 -05:00
chaincode-go Avoid usage of deprecated ioutil Go package (#843) 2022-10-25 07:04:39 -04:00
chaincode-java Remove JCenter as a Gradle package repository (#589) 2022-01-26 16:29:09 -05:00
README.md Private data samples migration (#574) 2022-03-09 08:51:48 +00:00

Asset transfer private data sample

The asset transfer private data sample demonstrates:

  • Usage of organization private data collections
  • Read data from the organization private data collection.
  • Store data in organization private data collection.

For more information about private data, visit the Private Data page in the Fabric documentation.

About the sample

This sample includes smart contract and application code in multiple languages. In a use-case similar to basic asset transfer (see asset-transfer-basic folder) this sample shows sending and receiving of asset along with its private data owned by organizations during create / delete of an asset , and during transfer of an asset to a new owner.

Application

Please refer the below link to understand the application flow. https://hyperledger-fabric.readthedocs.io/en/latest/private-data/private-data.html#example-scenario-asset-transfer-using-private-data-collections

Smart Contract

The smart contract (in folder chaincode-xyz) implements the following functions to support the application:

CreateAsset AgreeToTransfer TransferAsset DeleteAsset DeleteTranferAgreement

ReadAsset ReadAssetPrivateDetails ReadTransferAgreement GetAssetByRange QueryAssetByOwner QueryAssets getQueryResultForQueryString

Running the sample

Like other samples, the Fabric test network is used to deploy and run this sample. Follow these steps in order:

  1. Create the test network and a channel (from the test-network folder).

    ./network.sh up createChannel -c mychannel -ca
    
  2. Deploy one of the smart contract implementations (from the test-network folder).

    # To deploy the Java chaincode implementation
    ./network.sh deployCC -ccn private -ccp ../asset-transfer-private-data/chaincode-java  -ccl java -ccep "OR('Org1MSP.peer','Org2MSP.peer')"  -cccg '../asset-transfer-private-data/chaincode-java/collections_config.json' -ccep "OR('Org1MSP.peer','Org2MSP.peer')"
    
    # To deploy the go chaincode implementation
    ./network.sh deployCC -ccn private -ccp ../asset-transfer-private-data/chaincode-go  -ccl go -ccep "OR('Org1MSP.peer','Org2MSP.peer')"  -cccg '../asset-transfer-private-data/chaincode-go/collections_config.json' -ccep "OR('Org1MSP.peer','Org2MSP.peer')"
    
  3. Run the application (from the asset-transfer-private-data folder).

    # To run the Javascript sample application
    cd application-javascript
    npm install
    node app.js
    
    # To run the Typescript sample application
    cd application-gateway-typescript
    npm install
    npm start
    
    

Clean up

When you are finished, you can bring down the test network (from the test-network folder). The command will remove all the nodes of the test network, and delete any ledger data that you created.

./network.sh down