instantiated_chaincode – Manage a instantiated chaincode on a Hyperledger Fabric channel

Synopsis

Instantiate a chaincode on a Hyperledger Fabric channel by using the IBM Blockchain Platform.

This module works with the IBM Blockchain Platform managed service running in IBM Cloud, or the IBM Blockchain Platform software running in a Red Hat OpenShift or Kubernetes cluster.

Parameters

api_endpoint (required)

The URL for the IBM Blockchain Platform console.

Type: str
api_authtype (required)

ibmcloud - Authenticate to the IBM Blockchain Platform console using IBM Cloud authentication. You must provide a valid API key using api_key.

basic - Authenticate to the IBM Blockchain Platform console using basic authentication. You must provide both a valid API key using api_key and API secret using api_secret.

Type: str
api_key (required)

The API key for the IBM Blockchain Platform console.

Type: str
api_secret

The API secret for the IBM Blockchain Platform console.

Only required when api_authtype is basic.

Type: str
api_timeout

The timeout, in seconds, to use when interacting with the IBM Blockchain Platform console.

Type: int
Default value: 60
api_token_endpoint

The IBM Cloud IAM token endpoint to use when using IBM Cloud authentication.

Only required when api_authtype is ibmcloud, and you are using IBM internal staging servers for testing.

Type: str
Default value: https://iam.cloud.ibm.com/identity/token
state

absent - If a chaincode matching the specified name and version is instantiated, then an error will be thrown, as it is not possible to uninstantiate chaincode.

present - Asserts that a chaincode matching the specified name and version is instantiated on the specified channel. If it is not instantiated, then the chaincode with the specified name and version is instantiated on the specified channel. If it is instantiated with a different version, then the chaincode is upgraded on the specified channel. Otherwise, the instantiated chaincode is checked to ensure that it matches the specified ESCC and VSCC. It is not possible to check that the instantiated chaincode matches the specified endorsement policy and collections configuration. If the instantiated chaincode does not match, then an error will be thrown, as it is not possible to update instantiated chaincode without upgrading to a new version.

Type: str
Default value: present
peer (required)

The peer to use to manage the instantiated chaincode.

You can pass a string, which is the display name of a peer registered with the IBM Blockchain Platform console.

You can also pass a dict, which must match the result format of one of the ERROR while parsing: While parsing “M(peer_info)” at index 76: Module name “peer_info” is not a FQCN or ERROR while parsing: While parsing “M(peer)” at index 92: Module name “peer” is not a FQCN modules.

Type: raw
identity (required)

The identity to use when interacting with the peer.

You can pass a string, which is the path to the JSON file where the enrolled identity is stored.

You can also pass a dict, which must match the result format of one of the ERROR while parsing: While parsing “M(enrolled_identity_info)” at index 76: Module name “enrolled_identity_info” is not a FQCN or ERROR while parsing: While parsing “M(enrolled_identity)” at index 105: Module name “enrolled_identity” is not a FQCN modules.

Type: raw
msp_id (required)

The MSP ID to use for interacting with the peer.

Type: str
hsm

The PKCS #11 compliant HSM configuration to use for digital signatures.

Only required if the identity specified in identity was enrolled using an HSM.

Type: dict
pkcs11library

The PKCS #11 library that should be used for digital signatures.

Type: str
label

The HSM label that should be used for digital signatures.

Type: str
pin

The HSM pin that should be used for digital signatures.

Type: str
channel (required)

The name of the channel.

Type: str
name (required)

The name of the chaincode.

Type: str
version (required)

The version of the chaincode.

Type: str
constructor

The constructor for the chaincode.

Type: dict
function

The function name to call in the chaincode.

Type: str
args

The arguments to pass to the chaincode function.

Type: list
Elements: str
endorsement_policy

The endorsement policy for the chaincode.

Type: str
collections_config

The path to the collections configuration file for the chaincode.

Type: str
escc

The name of the endorsement system chaincode (ESCC) to use for the chaincode.

Type: str
Default value: escc
vscc

The name of the validation system chaincode (VSCC) to use for the chaincode.

Type: str
Default value: vscc
orderer_name

The name of the ordering service node to get the tls-certificate from

Type: str
Default value: the tls_cert for the orderering service will be found from the channel configuration

Examples

- name: Instantiate the chaincode on the channel
  ibm.blockchain_platform.instantiated_chaincode:
    state: present
    api_endpoint: https://ibp-console.example.org:32000
    api_authtype: basic
    api_key: xxxxxxxx
    api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    peer: Org1 Peer
    identity: Org1 Admin.json
    msp_id: Org1MSP
    channel: mychannel
    name: fabcar
    version: 1.0.0

- name: Instantiate the chaincode on the channel with an endorsement policy and collection configuration
  ibm.blockchain_platform.instantiated_chaincode:
    state: present
    api_endpoint: https://ibp-console.example.org:32000
    api_authtype: basic
    api_key: xxxxxxxx
    api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    peer: Org1 Peer
    identity: Org1 Admin.json
    msp_id: Org1MSP
    channel: mychannel
    name: fabcar
    version: 1.0.0
    endorsement_policy: AND('Org1MSP.peer', 'Org2MSP.peer')
    collections_config: collections-config.json

- name: Ensure the chaincode is not instantiated on the channel
  ibm.blockchain_platform.instantiated_chaincode:
    state: absent
    api_endpoint: https://ibp-console.example.org:32000
    api_authtype: basic
    api_key: xxxxxxxx
    api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    peer: Org1 Peer
    identity: Org1 Admin.json
    msp_id: Org1MSP
    channel: mychannel
    name: fabcar
    version: 1.0.0

Return Values

instantiated_chaincode

The instantiated chaincode.

Returned: when state is present
Type: dict
channel

The name of the channel.

Type: str
Sample: mychannel
name

The name of the chaincode.

Type: str
Sample: fabcar
version

The version of the chaincode.

Type: str
Sample: 1.0.0
escc

The name of the endorsement system chaincode (ESCC) used by the chaincode.

Type: str
Sample: escc
vscc

The name of the validation system chaincode (VSCC) used by the chaincode.

Type: str
Sample: vscc