List of articles

In the last article, we talked about how to IBM Cloud Build a blockchain environment and export and install the local smart contract in IBM Cloud In the network environment .

In this article, we will continue to explain how to use the local VSCode To remotely connect and call the IBM Cloud Smart contracts on the Internet .

from IBM Cloud Control panel export connection information

If the client needs to connect to Fabric The Internet , Need to pass through gateway To connect . If it's a real application , You need to use Hyperledger Fabric SDKs As gateway To connect Fabric The Internet .

Essentially VSCode It's also a client , therefore VSCode It can also be done through gateway To connect to remote Fabric The Internet .VSCode Of IBM blockchain extention Has been provided on the plug-in panel FABRIC GATEWAYS Options , We can use it directly here . Let's see how to configure a FABRIC GATEWAY.

Through the GATEWAY, We can do it in VSCode in , long-range submit/evaluate Network tranaction.

  1. First, create and register a connection account (enroll ID + secret).

In the last article , We talked about how to CA Create a new ID. The creation process is enroll The process of , Take this one ID stay CA Register in , And configure the corresponding permissions .

stay Nodes The palette , stay Certif Authorities in , We found what we created before CA : Org1 CA. Click on Register user. Input vscode and vscodepw As id and secret. choice Client As a type ,affiliation choice org1. maximum enrollments leave a blank . Click on next To create a new id.

Note that there maximum enrollments The role of ,maximum enrollments The biggest... Is specified enrollment frequency , If set to 1, Then ID Can only be enroll once , There's no use in the back . This is very useful when giving permissions to a given user .

  1. export Connection profile

We need to use the Connection profile To connect to Fabric The Internet . stay Smart contracts Select the previously instantiated smart contract in the panel , Click on … choice Connect with SDK, choice org1msp and Org1 CA As your MSP and Certificate Authority, And then click Download connection profile, Download it .

stay VSCode Created in gateway and wallet

  1. establish gateway

open IBM Blockchain Platform, stay FABRIC GATEWAYS Click on + , Input ibm_cloud As your gateway name , Next it needs you to choose one profile, Choose from above IBM Cloud Downloaded above profile, then gateway And we're done .

Click this gateway, He needs you to choose one wallet, Now let's see how to create wallet.

  1. establish wallet

stay FABRIC WALLETS Click on the + , choice Create a new wallet and add an identity, Give it a name :ibm_cloud_wallet, to identity Name it :id, Input org1msp As mspid, choice Select a gateway and provide an enrollment ID and secret, Choose the ibm_cloud, Input vscode and vscodepw As id and security. Then you can go to FABRIC WALLETS See the created identity 了 .

The story behind it : Just now we actually sent a enroll Ask to IBM Cloud above CA, And got a ID, And stored locally wallet Inside , For later use .

add to wallet after , If you click again ibm_cloud, Or will you choose one wallet, At this time, you can right-click ibm_cloud, choice Associate A Wallet, take ibm_cloud_wallet and ibm_cloud Connect , So you don't have to choose again every time .

stay VSCode Submitted in transaction

Now we have access to IBM Cloud Of gateway 了 . Next , Let's see what's going on VSCode Submitted in transaction.

  1. stay FABRIC GATEWAYS Click on the ibm_cloud.

  2. open Channels > channel1 > demoContract@0.0.1

  3. Right click on the myAssetExists, choice Evaluate Transaction. Input [“001”] As key, Because we don't have any value right now , So you'll see :

    [SUCCESS] Returned value from myAssetExists: false

  4. Right click on the createMyAsset, choice Submit Transaction Input [“001”, “hello ibm cloud”] , We have created a asset.

  5. Next we choose readMyAsset Of Evaluate Transaction Next input [“001”], We can see asset Successfully created .

    [SUCCESS] Returned value from readMyAsset: {"value":"hello ibm cloud"}

congratulations , You can already get it from the local VSCode Remote understanding IBM Cloud Fabric Network .

Let's see more :

For more tutorials, please refer to flydean The blog of