fabric-samples/asset-transfer-private-data
Stanislav Jakuschevskij 7244639e7c
Add off-chain-data go client application
Created project structure, fixed typos. Implemented connect.go and
getAllAssets.go. The latter uses an assetTransferBasic struct which
provides a simple API for basic asset operations like create, transfer,
etc.

Added transact.go with some util functions. Using google uuid package to
generate random UUIDs for the transactions.

Implemented pretty printing of JSON results.

Implemented app.go entry point with error handling. The existing
commands are getAllAssets, transact and listen. They can be called from
the command line via: "go run . <command> <command> ...". They will be
executed in order and if a command is not known an the application
panics and aborts before executing any of the commands.

Implementing listen.go. Added checkpointer, context setups, call to
BlockEvents and all the interfaces needed for parsing. Started
implementing the interfaces needed to represent a block bottom up in
structs. Finished NamespaceReadWriteSet, ReadWriteSet and
EndorserTransaction.

Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
2025-02-24 13:14:46 +01:00
..
application-gateway-go Add off-chain-data go client application 2025-02-24 13:14:46 +01:00
application-gateway-typescript Add private data go application 2024-10-31 16:30:25 -04:00
chaincode-go Update to Go 1.23 2025-02-12 08:34:17 -05:00
chaincode-java Update Gradle version and shadow plugin (#1278) 2024-12-11 08:04:56 -05:00
chaincode-typescript chore: use errors.New to replace fmt.Errorf with no parameters (#1277) 2024-12-10 11:15:02 +00:00
README.md Add private data go application 2024-10-31 16:30:25 -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
    
    # To run the Go sample application
    cd application-gateway-go
    go run .
    

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