Running fabric in IBM cloud

Time:2021-3-8

In the last article, we talked about how to use IBM blockchain platform extension to create a smart contract running locally in vs code editor.

After the smart contract is created, it can be run in its own blockchain environment or on major cloud platforms. At present, IBM, Tencent cloud, Alibaba cloud and AWS all provide SaaS services of blockchain, which can easily manage and expand the hyperledger fabric blockchain network. This article mainly describes how to run fabric smart contract on IBM cloud platform. In this way, we can have a very clear understanding of the process of deploying fabric blockchain. These steps and processes are also applicable even if they are deployed to our own network later.

Packaged smart contract

We will use the IBM blockchain platform extension on vs code to package smart contracts.

Open the smart contract panel in vs code, select the smart contract you want to export, right-click, select “export package”, find a location on your computer and save the. CDs file. Later, we will use this package smart contract to deploy on IBM blockchain platform 2.0 services.

Running fabric in IBM cloud

Now we will start setting up and configuring the hyperledger fabric network on the IBM cloud.

Creating IBM cloud services

Log in to IBM cloud and create IBM cloud kubernetes service. You can find the service in the directory. IBM cloud provides a free cluster instance, which will expire in 30 days. Note: kubernetes service setup may take 20 minutes to complete.

Running fabric in IBM cloud

Creating fabric network

After creating the blockchain platform, you can start to configure the fabric network.

We need to create an organization with a single peer, and its MSP and Ca (certification authority), as well as an order organization, and its MSP and ca. We will create the corresponding identities to deploy the peer node and operate the node.

Create org and corresponding nodes

  • Create peer org CA

    • Click Add certification authority.
    • Under create certification authority, click IBM cloud, and then click next.
    • Give it the name org1ca.
    • Specify admin as the admin ID and adminpw as the admin secret.

Running fabric in IBM cloud

  • Use this CA to register identities

    • Select the org1 CA certification authority we created.
    • First, we will register an administrator for the organization “org1”. Click the register user button. Enter org1admin as the registration ID and org1adminpw as the registration password. Click next to set the type of this identity to client, and then select associate all organizations from the drop-down list. We leave the “maximum number of registrations” and “add properties” fields blank.
    • We will repeat the process to create peer authentication. Click the register user button. Use peer1 as the registration ID and peer1pw as the registration password. Click next to set the identity type to peer, and then select associate all organizations from the drop-down list. We leave the “maximum number of registrations” and “add properties” fields blank.

Running fabric in IBM cloud

  • Create MSP of peer organization

    • Select organizations and click Create MSP definition
    • Use org1 MSP as “MSP display name” and org1msp as MSP ID.
    • Select org1 CA as the root CA of the organization.
    • The enrollment ID and enrollment secret of organization admin are org1admin and org1adminpw respectively. Identity name select org1 admin.
    • Click generate and export to generate the admin identity of the organization and export it to the local file system. Finally, click Create MSP definition to complete the creation of MSP.

Running fabric in IBM cloud

  • Create peer node

    • On the nodes page, click the add peer button and use peer org1 as the display name.
    • Select org1 CA as certificate authority.
    • Peer1 and peer1pw are used as the enroll ID and enroll secret. Org1 MSP as administrator certificate.
    • Admin and adminpw are used as TLS enroll ID and TLS enroll secret.
    • Org1 admin as associate an identity.

Running fabric in IBM cloud

Create order org and corresponding nodes

The steps to create order org and peer org are highly similar.

  • Create order org CA

    • Click Add certificate authority and set the orderer CA to display name.
    • Admin and adminpw are admin ID and admin secret.
  • Use this CA to register order admin and order authentication

    • Select the orderer Ca and click register user.
    • Ordereradmin and ordereradminpw are used as the enroll ID and enroll secret. Select client as the type.
    • Click register user, and enter orderer1 and orderer1pw as the enroll ID and enroll secret. Select peer as the type.

Running fabric in IBM cloud

  • Create MSP of order ORG

    • Click Create MSP definition, order MSP as MSP display name, and orderermsp as MSP ID.
    • The orderer CA serves as the root certificate authority.
    • Ordereradmin and ordereradminpw are used as the enroll ID and enroll secret. Orderer admin as identity name.
    • Click Create MSP definition to complete the creation.

Running fabric in IBM cloud

  • Create order node

    • Click add order, order as display name and order CA as certificate authority.
    • Orderer1 and orderer1pw are used as the enroll ID and enroll secret.
    • Orderer MSP as administrator certificate.
    • Admin and adminpw are used as TLS enroll ID and TLS enroll secret
    • Order admin as associate an identity.

Running fabric in IBM cloud

  • Associate order and peer

    • Click on the orderer we just created.
    • Under consortium members, click Add organization.
    • Select org1 MSP and click Submit.

Running fabric in IBM cloud

Create and join channel

  • Create channel

    • Click Create channel and name the channel mychannel
    • Select the order you just created, and select org1 MSP (org1msp) as the MSP.
    • Org1 admin as association authentication.
    • Click Add and select operator.
    • Click create

Running fabric in IBM cloud

  • Adding peer to channel

    • Click join channel, select orderer, select mychannel, and select peer: peer org1 to join. Submit.

Running fabric in IBM cloud

It’s complicated, but congratulations, you’ve created a fabric network.

Import smart contract

  • Installing smart contracts

    • Click smart contracts, click Install smart contract, and select the smart contract we exported before.
    • Click add file, click Install.

Running fabric in IBM cloud

  • Instantiate smart contract

    • In the smart Contracts tab, find the smart contract you just installed.
    • Click instant, select mychannel, and select org1msp.
    • Click instant.

Well, the smart contract is perfectly deployed on the IBM cloud.

For more tutorials, please refer to flydean’s blog