Skip to content

Installing and instantiating chaincode in Bevel deployed Hyperledger Fabric Network

Pre-requisites

Hyperledger Fabric network deployed and network.yaml configuration file already set.

Modifying configuration file

Refer this guide for details on editing the configuration file.

The network.yaml file should contain the specific network.organizations.services.peers.chaincodes section, which is consumed when the chaincode-ops playbook is run

For reference, following snippet shows that section of network.yaml

          consensus: raft
          grpc:
            port: 7050
          ordererAddress: orderer3.org1proxy.blockchaincloudpoc.com:443

    # Specification for the 2nd organization. Each organization maps to a VPC and a separate k8s cluster
    - organization:
      name: manufacturer
      ..
      ..
        attributes:
          name: ca
          subject: "/C=CH/ST=Zurich/L=Zurich/O=Manufacturer/CN=ca.manufacturer-net.org2proxy.blockchaincloudpoc.com"
          type: ca
          grpc:
            port: 7054
        peers:
        - peer:
          name: peer0          
          type: anchor    # This can be anchor/nonanchor. Atleast one peer should be anchor peer.         
          gossippeeraddress: peer0.manufacturer-net:7051 # Internal Address of the other peer in same Org for gossip, same peer if there is only one peer 
          peerAddress: peer0.manufacturer-net.org2proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer 
          certificate: /path/manufacturer/peer0.crt # Path to peer Certificate
          cli: disabled      # Creates a peer cli pod depending upon the (enabled/disabled) tag.
          cactus_connector: disabled  # set to enabled to create a cactus connector for Fabric
          grpc:
            port: 7051
          events:
            port: 7053
          couchdb:
            port: 5984
          restserver:           # This is for the rest-api server
            targetPort: 20001
            port: 20001
          expressapi:           # This is for the express api server
            targetPort: 3000
            port: 3000
          chaincodes:
            - name: "chaincode_name" #This has to be replaced with the name of the chaincode
              version: "1" #This has to be replaced with the version of the chaincode
              sequence: "1" #sequence of the chaincode, update this only for chaincode upgrade
              maindirectory: "chaincode_main"  #The main directory where chaincode is needed to be placed
              lang: "golang"  # The language in which the chaincode is written ( golang/java/node )
              repository:
                username: "git_username"          # Git Service user who has rights to check-in in all branches
                password: "git_access_token"

Chaincode Operations in Bevel for the deployed Hyperledger Fabric network

The playbook chaincode-ops.yaml is used to install and instantiate chaincode for the existing fabric network. For Fabric v2.2 and 2.5 multiple operations such as approve, commit and invoke the chaincode are available in the same playbook. This can be done by using the following command

ansible-playbook platforms/hyperledger-fabric/configuration/chaincode-ops.yaml --extra-vars "@path-to-network.yaml"

NOTE: The same process is executed for installing and instantiating multiple chaincodes