A recent commit added the potential buyer to an asset's state based endorsement policy. That change was problematic because if the transfer fell through, the buyer lost control of the asset, in that they could no longer update the asset or change the sell price or sell to somebody else. The asset state based endorsement policy is now based on the seller only, and we document that additional parties could be added such as a trusted third party (although no such party exists in test network at this time). This commit also re-adds some necessary verifications, and make other minor edits and comments to help users understand the sample. Signed-off-by: David Enyeart <enyeart@us.ibm.com> |
||
|---|---|---|
| .. | ||
| application-gateway-typescript | ||
| application-javascript | ||
| chaincode-go | ||
| README.md | ||
Asset transfer secured agreement sample
The asset transfer events sample demonstrates how to transfer a private asset between two organizations without publicly sharing data .
About the sample
This sample includes smart contract and application code in multiple languages. This sample shows how Fabric features state based endorsement, private data, and access control to provide secured transactions.
Application
Refer Secured asset transfer in Fabric for application details .
Smart Contract
The smart contract (in folder chaincode-go) implements the following functions to support the application:
- CreateAsset
- ChangePublicDescription
- AgreeToSell
- AgreeToBuy
- VerifyAssetProperties
- TransferAsset
- ReadAsset
- GetAssetPrivateProperties
- GetAssetSalesPrice
- GetAssetBidPrice
- GetAssetHashId
- QueryAssetSaleAgreements
- QueryAssetBuyAgreements
- QueryAssetHistory
Running the sample
Like other samples, the Fabric test network is used to deploy and run this sample. Follow these steps in order:
-
Create the test network and a channel (from the
test-networkfolder)../network.sh up createChannel -c mychannel -ca -
Deploy the smart contract implementations.
# To deploy the go chaincode implementation ./network.sh deployCC -ccn secured -ccp ../asset-transfer-secured-agreement/chaincode-go/ -ccl go -ccep "OR('Org1MSP.peer','Org2MSP.peer')" -
Run the application (from the
asset-transfer-secured-agreementfolder).# To run the Typescript sample application cd application-gateway-typescript npm install npm start # To run the Javascript sample application cd application-javascript node app.js
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