The Asset Management App tests the behavior of asset management chaincode. The app bootstraps a non-validating peer and constructs fabric confidential transactions to deploy, invoke and query the asset management chaincode as described below.
In particular, we consider a scenario in which we have the following parties:
- Alice is the chaincode deployer;
- Bob is the chaincode administrator;
- Charlie and Bob are asset owners;
that interact in the following way:
- Alice deploys and assigns the administrator role to Bob;
- Bob assigns the asset 'Picasso' to Charlie;
- Charlie transfers the ownership of 'Picasso' to Dave;
In the following sections, we describe in more detail the interactions described above that the asset management app exercises.
The following actions take place:
- Alice obtains, via an out-of-band channel, a TCert of Bob, let us call this certificate BobCert;
- Alice constructs a deploy transaction, as described in application-ACL.md, setting the transaction metadata to DER(BobCert).
- Alice submits the deploy transaction to the fabric network.
Bob is now the administrator of the chaincode.
Notice that, to assign ownership of assets, Bob has to use BobCert to authenticate his invocations.
- Bob obtains, via an out-of-band channel, a TCert of Charlie, let us call this certificate CharlieCert;
- Bob constructs an invoke transaction, as described in application-ACL.md using BobCert to gain access, to invoke the assign function passing as parameters ('Picasso', Base64(DER(CharlieCert))).
- Bob submits the transaction to the fabric network.
Charlie is now the owner of 'Picasso'.
Notice that, to transfer the ownership of 'Picasso', Charlie has to use CharlieCert to authenticate his invocations.
- Charlie obtains, via an out-of-band channel, a TCert of Dave, let us call this certificate DaveCert;
- Charlie constructs an invoke transaction, as described in application-ACL.md using CharlieCert, to invoke the transfer function passing as parameters ('Picasso', Base64(DER(DaveCert))).
- Charlie submits the transaction to the fabric network.
Dave is now the owner of 'Picasso'
In order to run the Asset Management App, the following steps are required.
The app needs a 'core.yaml' configuration file in order to bootstrap a non-validating peer. This configuration file can be copied from fabric/peer/core.yaml.
We consider the fabric network as described here: https://github.com/hyperledger/fabric/blob/master/consensus/docker-compose-files/compose-consensus-4.md that consists of 4 validators and the membership service.
Before setting up the network, the fabric/peer/core.yaml file must be modified by setting the following properties as specified below:
- security.enabled = true
- security.privacy = true
Moreover, the 'core.yaml' file used to configure the app must point to the fabric network setup above. This can be done by replacing:
- '0.0.0.0' with 'vp0';
- 'localhost' with membersrvc.
Once the network is up, do the following:
- From a vagrant terminal, run this command:
docker exec -it dockercomposefiles_cli_1 bash
- Change folder to:
cd $GOPATH/src/github.com/hyperldger/fabric/examples/chaincode/go/asset_management/app
- Build the app
go build
- Run the app
./app
If everything works as expected then you should see the output of the app without errors.