Instantiate PaperNet Chaincode (Smart Contract)

Q

How to Instantiate the PaperNet Chaincode (Smart Contract), papercontract.js?

✍: FYIcenter.com

A

Now that papercontract chaincode containing the CommercialPaper chaincode is installed on the required PaperNet peers, you, as administrator, can make it available to different network channels, so that it can be invoked by applications connected to those channels. Because we’re using the basic network configuration for PaperNet, we’re only going to make papercontract available in a single network channel, mychannel.

1. Instantiate the chaincode:

(magnetocorp admin)$ cd ~/hyperledger-binaries/fabric-samples
(magnetocorp admin)$ cd commercial-paper/organization/magnetocorp/contract
(magnetocorp admin)$ docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract \
   -v 0 -l node -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' \
   -C mychannel -P "AND ('Org1MSP.member')"

[chaincodeCmd] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) \
   orderer endpoint: orderer.example.com:7050
[chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default escc
[chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default vscc
^C

You may need to press Ctrl-C to exit from the cliMagnetoCorp container.

Note that the orderer address orderer.example.com:7050 in the log message. This is because it additionally submits an instantiate transaction to the orderer, which will include the transaction in the next block and distribute it to all peers that have joined mychannel, enabling any peer to execute the chaincode in their own isolated chaincode container. Note that instantiate only needs to be issued once for papercontract even though typically it is installed on many peers.

2. Verify the instantiated chaincode:

(magnetocorp admin)$ docker exec cliMagnetoCorp peer chaincode list --instantiated -C mychannel
Get instantiated chaincodes on channel mychannel:
Name: papercontract, Version: 0, Path: /opt/gopath/src/github.com/contract, Escc: escc, Vscc: vscc

3. Verify the container that runs the instantiated chaincode:

(magnetocorp admin)$ docker ps | grep papercontract

IMAGE                                              STATUS        NAMES
dev-peer0.org1.example.com-papercontract-0-d96...  Up 2 minutes  dev-peer0.org1.example.com-papercontract-0

Commercial Paper Network - Instantiate Chaincode

 

Client Application Gateway

Install PaperNet Chaincode (Smart Contract)

commercial-paper Sample Network

⇑⇑ Hyperledger Tutorials

2019-12-02, 202👍, 0💬