fabric-samples/asset-transfer-private-data
Mark S. Lewis f16e9e6de5 Consistent Go version in go.mod and go.work files
The repository currently uses Go 1.22 to test samples in the automated
build. This change sets the Go version in all go.mod (and go.work) files
to Go 1.22.0, and removes any Go toolchain entries.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-10-14 10:25:34 -04:00
..
application-gateway-typescript Explicitly specify hash in client applications 2024-10-07 12:25:40 -04:00
chaincode-go Consistent Go version in go.mod and go.work files 2024-10-14 10:25:34 -04:00
chaincode-java Update test dependencies for Java chaincode 2024-05-21 22:19:39 -04:00
chaincode-typescript Use more specific chaincode package versions 2024-06-14 00:24:08 -04:00
README.md Remove legacy sample applications 2024-06-19 10:38:52 -04: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')"
    
    # To deploy the typescript chaincode implementation
    ./network.sh deployCC -ccn private -ccp ../asset-transfer-private-data/chaincode-typescript/ -ccl typescript  -ccep "OR('Org1MSP.peer','Org2MSP.peer')" -cccg ../asset-transfer-private-data/chaincode-typescript/collections_config.json 
    
  3. Run the application (from the asset-transfer-private-data folder).

    # 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