Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to connect to IBM Cloud block chain network in VSCode

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to connect to the IBM Cloud blockchain network in VSCode, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Export connection information from the IBM Cloud Control Panel

If the client needs to connect to the Fabric network, it needs to be connected through gateway. If it is a real application, you need to connect to the Fabric network by using Hyperledger Fabric SDKs as the gateway.

VSCode is essentially a client, so VSCode can also connect to remote Fabric networks through gateway. VSCode's IBM blockchain extention already provides the FABRIC GATEWAYS option on the plugins panel, so we can just use it here. Let's look at how to configure a FABRIC GATEWAY.

Through this GATEWAY, we can use tranaction in VSCode, remote submit/evaluate network.

First create and register a connected account (enroll ID + secret).

In the last article, we talked about how to create a new ID in CA. The process of creating this is the process of enroll. Register the ID in CA and configure the appropriate permissions.

In the Nodes panel, in Certif Authorities, we find the CA: Org1 CA that we created earlier. Click Register user. Enter vscode and vscodepw for id and secret. Select Client as the type and affiliation select org1. Maximum enrollments is left blank. Click next to create a new id.

Note the role of maximum enrollments here. Maximum enrollments specifies the maximum number of enrollment. If set to 1, the ID can only be enroll once, and it will be useless later. This is useful when granting permissions to a specified user.

Export Connection profile

We need to use Connection profile to connect to the Fabric network. For a smart contract instantiated before the Smart contracts panel is selected, click … Select Connect with SDK, select org1msp and Org1 CA as your MSP and Certificate Authority, and then click Download connection profile to download it.

Create gateway and wallet in VSCode

Create gateway

Open IBM Blockchain Platform, click + in FABRIC GATEWAYS, type ibm_cloud as your gateway name, and then it requires you to select a profile, select the profile downloaded from IBM Cloud above, and the gateway is created.

Click on the gateway, he needs you to select a wallet, let's take a look at how to create a wallet.

Create wallet

Click + in FABRIC WALLETS, select Create a new wallet and add an identity, give it a name: ibm_cloud_wallet, give identity a name: id, enter org1msp as mspid, select Select a gateway and provide an enrollment ID and secret, select the ibm_cloud you just created, and enter vscode and vscodepw as id and security. Then you can see the created identity in FABRIC WALLETS.

The story behind: just now we actually sent an enroll request to the CA on IBM Cloud, and got an ID and stored it in the local wallet for later use.

After adding wallet, if you click ibm_cloud again, you will still be asked to select a wallet. At this time, you can right-click ibm_cloud and select Associate A Wallet to associate ibm_cloud_wallet with ibm_cloud, so you don't have to choose again every time.

Submit transaction in VSCode

Now we have a gateway that can connect to IBM Cloud. Next, let's take a look at how to submit a transaction in VSCode.

Click ibm_cloud in FABRIC GATEWAYS.

Open Channels > channel1 > demoContract@0.0.1

Right-click myAssetExists and select Evaluate Transaction. Enter ["001"] as the key, because we don't have any values right now, so you'll see:

[SUCCESS] Returned value from myAssetExists: false

Right-click createMyAsset, select Submit Transaction, type ["001", "hello ibm cloud"], and we have created an asset.

Next, we select the Evaluate Transaction of readMyAsset, and then enter ["001"], and we can see that the asset has been created successfully.

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

On how to connect to the IBM Cloud block chain network in VSCode to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report