All Products
Search
Document Center

Use Hyperledger Composer

Last Updated: Aug 07, 2019

This document describes how to deploy and use Hyperledger Composer in the Alibaba Cloud BaaS console. For more information about Hyperledger Composer, see Documentation.

Prerequisites

You have installed Docker (version 17 or later) on Linux or Windows. You have a basic understanding of Hyperledger Composer and you are familiar with the basic operations.

Quick deployment

This example uses "quick mode" to create a consortium named "composer" and two organizations named "composer1" and "composer2", respectively. The user name is "composer".

  1. Log on to the Alibaba Cloud BaaS console. In My Organizations, locate the organization named "composer1", and click the name "composer1" to enter the Basic Information page. Click the Users tab and then click Add User. The name of the new user is "composer" .Users

  2. "Download SDK Configuration". Decompress the SDK to the local disk. Open a command shell and go to the decompressed SDK directory. You can use command-line shells, such as CMD, Bash, and PowerShell. This example uses the CMD shell.Directory

  3. Modify the baas-sdk-composer@composer1.aliyunbaas.top\composer\cards\composer\metadata.json file. Change the userName parameter to "composer" and the enrollmentSecret parameter to the password of the user "composer".

    1. {
    2. "version": 1,
    3. "userName": "composer", // username
    4. "businessNetwork": null,
    5. "enrollmentSecret": "********", // password
    6. "roles": [
    7. "PeerAdmin",
    8. "ChannelAdmin"
    9. ]
    10. }
  4. Modify the baas-sdk-composer@composer1.aliyunbaas.top\composer\cards\composer\connection.json file based on your needs. For more information, see Hyperledger Composer Documentation. Only one channel key can be reserved. The channel key of the channel named "first-channel" is reserved in this example.

  5. Run commands in a shell script. We recommend that you back up the composer folder before running the commands.

    1. # REM CMD command
    2. set PWD=%CD:\=/%
    3. docker run --rm -ti -v %PWD%/composer:/home/composer/.composer -e PORT=8080 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/aliyun-blockchain/baas-composer:0.20.0
    1. # PowerShell command
    2. $P=$PWD.Path.Replace("\", "/")
    3. docker run --rm -ti -v $P/composer:/home/composer/.composer -e PORT=8080 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/aliyun-blockchain/baas-composer:0.20.0
    1. # Bash command
    2. docker run -u 0 --rm -ti -v $PWD/composer:/root/.composer -e PORT=8080 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/aliyun-blockchain/baas-composer:0.20.0

    run cmd

  6. Open Hyperledger Composer in a browser.

    Hyperledger Composer

Quick start

  1. Click Deploy a New Business Network to deploy a new composer business network using the name and the password of the user "composer". You can specify multiple admin users by separating each with a comma, for example, "user1,user2,user3,…”. However, you can only specify one password, which is the password of the first user.

    us

  2. Click Download. In the Save dialog box displayed, click Save. You cannot use the new Business Network Card displayed at the same time. The @install package is generated.

    Card

  3. Log on to the Alibaba Cloud BaaS console. In My Organizations, locate "composer1" and click the name to enter the Basic Information page. Click the Chaincodes tab and then click Upload Chaincode (Use the ccpack downloaded in Step 2. Install and instantiate the chaincode.UploadInstallInstantiate

  4. Go back to Hyperledger Composer. Click Connect now. We recommend that you delete the peer node in the group named "composer2" for quicker processing. The group "composer2" is in the channel "first-channel" in the file named "connection.json". It may take a while before you can enter the dev mode and start development.dev

  5. Click Deploy changes. In the Save dialog box displayed, click Save. The @upgrade package is generated.

  6. Use the new ccpack to upgrade the chaincode. You have now completed the chaincode installation and Hyperledger Composer upgrade. All functions with the exception of the Issue New ID function are the same as that of Hyperledger Composer.Upgrade

  7. The ID Name for the Issue New ID operation uses the "username,password" format. The username must be a user managed by the Alibaba Cloud BaaS console.Issue

Notes

  1. There is only one channel in the connection.json file, and the channel must be the same as the channel joined by the user’s organization.
  2. Reducing the number of peer nodes and orderer nodes in the file named "connection.json" can accelerate the connection speed to the Alibaba Cloud BaaS console.
  3. The @install package and the @upgrade package correspond to the new composer business network and the upgraded composer business network, respectively. Pay attention to applicable scenarios to prevent errors or data loss.
  4. Secure and backup the Business Network Card to prevent data loss or management problems.