Updated on 2023-01-16 GMT+08:00

Installing and Instantiating a Chaincode

A chaincode must be installed on all peers in a channel and instantiated on any one peer. To use the same chaincode, channel members must specify the same name and version for the chaincode during chaincode installation.

  • The chaincode must be installed by the inviting party and all invitees (in this demo, invitees A and B).
  • The chaincode name and version specified by all parties must be consistent.
  • The chaincode can be instantiated by any member in the consortium.

Installing a Chaincode

  1. Log in to the BCS console.
  2. In the navigation pane on the left, click Instance Management.
  3. On a target instance card, click Manage Blockchain.
  4. On the login page, enter the username and password, and click Log In.

    • The username is admin, and the password is the Blockchain Mgmt. Initial Password set when you created the BCS instance. If you have not set this password, use the resource access initial password. For security purposes, change the password periodically.
    • If you use the Internet Explorer, you may fail to open the Blockchain Management login page and see a message indicating that the certificate is untrusted. In this case, you can click here to resolve the problem.

  5. Click Install Chaincode in the upper left corner of the page.
  6. Enter the chaincode name and version number, select the peers where the chaincode is to be installed, specify the programming language of the chaincode, and add the chaincode file, as described in Table 1.

    Table 1 Parameters

    Parameter

    Setting

    Chaincode Name

    Enter fabbank.

    Chaincode Version

    Enter 1.0.

    Ledger Storage

    File database (GoLevelDB)

    Select All Peers

    Select the checkbox.

    Organization & Peer

    All peers have been selected automatically.

    Language

    Select Golang.

    Chaincode File

    Log in to the BCS console and choose Use Cases. Download Bank_Demo in the SDK Demo for a Bank Consortium Blockchain area.

    Chaincode Description

    Enter a description of the chaincode.

    Code Security Check

    This option is displayed only when the chaincode language is Golang. Enable this option to check chaincode security.

  7. Click Install to install the chaincode.

Instantiating a Chaincode

  1. After installing the chaincode, click Instantiate in the Operation column of the chaincode list.
  2. Specify the channel for instantiation, chaincode version, endorsement policy, endorsing organizations, and chaincode parameters, as described in Table 2.

    Table 2 Parameters

    Parameter

    Setting

    Chaincode Name

    Enter fabbank.

    Channel

    Select testchannel.

    Chaincode Version

    Select 1.0.

    Initialization Function

    Enter init.

    Chaincode Parameters

    -

    Endorsement Policy

    Select Endorsement from any of the following organizations.

    Endorsing Organizations

    Select all the three organizations.

    Privacy Protection

    Select No.

  3. Click Instantiate.

    Wait for 2 to 3 minutes and refresh the page. Click View more to check the instantiation status.