tencent cloud

Integrating v2.3 Network
Last updated:2025-04-10 00:41:11
Integrating v2.3 Network
Last updated: 2025-04-10 00:41:11
Note:
Blockchain SDK integration with network API call method supports Fabric network.
If the application system has a relatively high call frequency, it is required to directly use Blockchain SDK to connect with the blockchain network, which has higher performance compared with TencentCloud API call method.
In addition to supporting the community edition of Blockchain SDK (Java, NodeJS, Golang), TBaaS has customized the community edition Blockchain SDK for Golang and Java versions (tbaas-fabric-sdk-go and tbaas-fabric-sdk-java), simplifying the process of connecting application systems to the blockchain network.

1. Get the Network Name and Access Address

1. Log in to TBaaS Console, select Fabric > Blockchain Network in the left sidebar.
2. On the Blockchain Network page, select the network you want to view and click Manage to enter the network overview page.
3. In the Network Basic Information module, find the network name and access address, and fill in the relevant fields of network name and url in the configuration file. As shown below:




2. Obtain MSP and Organization Name

1. In the Organization and Node tab, select Network Organization.
2. Find the current organization information and fill in the relevant fields of MSP in the configuration file; extract the part on the left of ., such as org-251005746, and fill in the relevant fields of organization name in the configuration file. As shown below:




3. Obtain Node Name

1. In the Organization and Node tab, select Node Management.
2. Find the node list of the current organization, select a node and copy the node name, then fill it in the field about node name in the configuration file. As shown below:




4. Deploy Contract

1. In the Contract Management tab, click Create Contract.
2. In Create Contract, fill in the following basic information:
contract name: fill in mycc
contract version: fill in v1.0
Select contract language: Select Go
upload the contract compressed package
3. Click installation, and choose a peer node.



4. Click contract instantiation, and wait for the contract status to update to "instantiated".

5. Certificate Application Process

1. Go to the OpenSSL official website, download OpenSSL, and configure the installation.
2. Download the ecccsr tool. After decompressing it, execute sh ecccsr.sh. This command will generate the following four files:
user_ecc_sign.key: It corresponds to the private key of the user certificate, needs to be securely stored, and can be used in SDK.
user_ecc_sign.csr: Used to apply for a user certificate on the TBaaS Console.
user_ecc_tls.key: It is the private key corresponding to the user's TLS certificate, requires secure storage, and can be used in SDK.
user_ecc_tls.csr: Used to apply for a user TLS certificate on the TBaaS Console.
3. In the Certificate Management interface, add a certificate application, complete the certificate identifier, and upload user_ecc_sign.csr and user_ecc_tls.csr. As shown below:



4. After a successful application, you can click to download the corresponding certificate. The compressed package contains the following files:
ca.crt: organization root certificate
user_sign.crt: user certificate
user_tls.crt: User TLS certificate
5. Place three certificates (ca.crt, user_sign.crt, user_tls.crt) and two private keys (user_ecc_sign.key, user_ecc_tls.key) in the corresponding SDK certificate directory and replace them. Modify the corresponding path in the SDK configuration file config.yml.

6. Using the SDK

6.1 tbaas-fabric-sdk-go

1. Download and enter tbaas-fabric-sdk-go, then enter the tbaas-fabric-sdk-go/fabric-sdk-demo directory.
2. Modify configFile, mspId, username, channelName, and contractName in the main.go example code accordingly. The example is as follows:
const (
configFile = "config/config.yaml"
// Organization MSPID
mspId = "org-251005746.fabric-5x6wdaow3q"
// userName
username = "test"
// Channel name
channelName = "channel-9xjcb2"
// contract name
contractName = "gotest"
)
3. Update the related content in the yml configuration file.
version: 1.0.0
client:
# The organization used by default by the client
organization: org-251005746
logging:
# sdk log level
level: info
tlsCerts:
client:
# user TLS private key path
key:
path: config/test/user_ecc_tls.key
# User TLS certificate path
cert:
path: config/test/user_tls.crt
# Channel information
channels:
# Channel name
channel-9xjcb2:
# peer node list
peers:
# peer node name
peer1-org-251005746.fabric-5x6wdaow3q:
# orderer node list
orderers:
- orderer1-org-251005746.fabric-5x6wdaow3q
# Organization information
organizations:
# organization name
org-251005746:
# Organization mspId, format is ${orgName}.${clusterId}, where orgName is the organization name and clusterId is the network ID
mspid: org-251005746.fabric-5x6wdaow3q
# Node list under this organization
peers:
- peer1-org-251005746.fabric-5x6wdaow3q
# organization user
users:
# userName
test:
# user private key path
key:
path: config/test/user_ecc_sign.key
# User certificate path
cert:
path: config/test/user_sign.crt
# Node Information
peers:
# peer node name
peer1-org-251005746.fabric-5x6wdaow3q:
# peer node url
url: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
grpcOptions:
# SNI in peer node TLS, use node name
ssl-target-name-override: peer1-org-251005746.fabric-5x6wdaow3q
# TLS CA certificate path
tlsCACerts:
path: config/test/ca.crt
entityMatchers:
peer:
# Need to configure to initiate peer
- pattern: (\\w*)peer1-org-251005746.fabric-5x6wdaow3q(\\w*)
mappedHost: peer1-org-251005746.fabric-5x6wdaow3q
# Configuration for multi-organization endorsement as follows. The first three items should be configured as PeerName of other endorsement organizations. urlSubstitutionExp is consistent with that of the orderer.
# - pattern: peer1-org-251005762.fabric-5x6wdaow3q
# mappedHost: peer1-org-251005762.fabric-5x6wdaow3q
# sslTargetOverrideUrlSubstitutionExp: peer1-org-251005762.fabric-5x6wdaow3q
# urlSubstitutionExp: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
orderer:
- pattern: (\\w+)
sslTargetOverrideUrlSubstitutionExp : "${1}"
urlSubstitutionExp: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
4. Execute the following command:
go run main.go
Successful execution can view the output as shown in the figure below.




6.2 tbaas-fabric-sdk-java

2. Install the jar package as per the Readme document.
3. Modify wallet, identity, network, username, and contract in the eccDemo.java example code accordingly.
4. Update the related content in the yml configuration file.
name: test-net
version: 1.0.0
client:
# The organization used by default by the client
organization: org-251005746
logging:
# sdk log level
level: info
tlsCerts:
client:
# user TLS private key path
key:
path: src/main/resources/crypto-config/eccUser/user_ecc_tls.key
# User TLS certificate path
cert:
path: src/main/resources/crypto-config/eccUser/user_tls.crt
# Channel information
channels:
# Channel name
channel-9xjcb2:
# peer node list
peers:
# peer node name
peer1-org-251005746.fabric-5x6wdaow3q:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
# orderer node list
orderers:
- orderer1-org-251005746.fabric-5x6wdaow3q
# Organization information
organizations:
# organization name
org-251005746:
# Organization mspId, format is ${orgName}MSP-${clusterId}, where orgName is the organization name and clusterId is the network ID
mspid: org-251005746.fabric-5x6wdaow3q
# Node list under this organization
peers:
- peer1-org-251005746.fabric-5x6wdaow3q
# organization user
users:
# userName
eccUser:
# user private key path
key:
path: src/main/resources/crypto-config/eccUser/user_ecc_sign.key
# User certificate path
cert:
path: src/main/resources/crypto-config/eccUser/user_sign.crt
# Node Information
peers:
# peer node name
peer1-org-251005746.fabric-5x6wdaow3q:
# peer node url
url: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
grpcOptions:
# SNI in peer node TLS, use node name
hostnameOverride: peer1-org-251005746.fabric-5x6wdaow3q
# TLS CA certificate path
tlsCACerts:
path: src/main/resources/crypto-config/eccUser/ca.crt
# Node Information
orderers:
# peer node name
orderer1-org-251005746.fabric-5x6wdaow3q:
# peer node url
url: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
grpcOptions:
# SNI in peer node TLS, use node name
hostnameOverride: orderer1-org-251005746.fabric-5x6wdaow3q
# TLS CA certificate path
tlsCACerts:
path: src/main/resources/crypto-config/eccUser/ca.crt
entityMatchers:
peer:
- pattern: (\\w*)peer1-org-251005746.fabric-5x6wdaow3q(\\w*)
mappedHost: peer1-org-251005746.fabric-5x6wdaow3q
- pattern: (\\w+)
sslTargetOverrideUrlSubstitutionExp: "${1}"
urlSubstitutionExp: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
orderer:
- pattern: (\\w+)
sslTargetOverrideUrlSubstitutionExp : "${1}"
urlSubstitutionExp: grpcs://org-251005746-fabric-5x6wdaow3q.tbaas.tech:8080
5. Run eccDemo.java.
6. Successful execution can view the output: "After transaction: 20".
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback