Skip to content

Commit

Permalink
[FAB-18109] Update peer chaincode invoke
Browse files Browse the repository at this point in the history
Need to describe how to target a specific smart contract inside
a chaincode package.
- Added a new example to peer chaincode invoke
- Added instructions to writing your first application tutorial.

Content is already included in the Developing Apps documentation.

Signed-off-by: pama-ibm <pama@ibm.com>
(cherry picked from commit 724f464)
  • Loading branch information
pamandrejko authored and mergify[bot] committed Aug 18, 2020
1 parent e042657 commit 14ad1d7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/source/commands/peerchaincode.md
Expand Up @@ -382,6 +382,18 @@ Here is an example of the `peer chaincode invoke` command:
successfully. The transaction will then be added to a block and, finally, validated
or invalidated by each peer on the channel.

Here is an example of how to format the `peer chaincode invoke` command when the chaincode package includes multiple smart contracts.

* If you are using the [contract-api](https://www.npmjs.com/package/fabric-contract-api), the name you pass to `super("MyContract")` can be used as a prefix.

```
peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyContract:methodName", "{}"] }'
peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyOtherContract:methodName", "{}"] }'
```


### peer chaincode list example

Here are some examples of the `peer chaincode list ` command:
Expand Down
7 changes: 7 additions & 0 deletions docs/source/write_first_app.rst
Expand Up @@ -340,9 +340,16 @@ to the Contract using the contract name and channel name via Gateway:
// Build a network instance based on the channel where the smart contract is deployed
const network = await gateway.getNetwork(channelName);
// Get the contract from the network.
const contract = network.getContract(chaincodeName);
When a chaincode package includes multiple smart contracts, on the `getContract() API <https://hyperledger.github.io/fabric-sdk-node/release-2.2/module-fabric-network.Network.html#getContract>`__ you can specify both the name of the chaincode package and a specific smart contract to target. For example:
.. code:: bash
const contract = await network.getContract('chaincodeName', 'smartContractName');
Fourth, the application initializes the ledger with some sample data
--------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions docs/wrappers/peer_chaincode_postscript.md
Expand Up @@ -66,6 +66,18 @@ Here is an example of the `peer chaincode invoke` command:
successfully. The transaction will then be added to a block and, finally, validated
or invalidated by each peer on the channel.

Here is an example of how to format the `peer chaincode invoke` command when the chaincode package includes multiple smart contracts.

* If you are using the [contract-api](https://www.npmjs.com/package/fabric-contract-api), the name you pass to `super("MyContract")` can be used as a prefix.

```
peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyContract:methodName", "{}"] }'
peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyOtherContract:methodName", "{}"] }'
```


### peer chaincode list example

Here are some examples of the `peer chaincode list ` command:
Expand Down

0 comments on commit 14ad1d7

Please sign in to comment.