Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Chaincode Invoking (OBT)

Updated on 2023-03-01 GMT+08:00

Function

This API is used to invoke and query the instantiated chaincodes of deployed BCS services.

URI

POST /v1/chaincode/operation

Request

Table 1 Request parameters

Parameter

Mandatory

Type

Description

channelId

Yes

String

Channel ID in a blockchain.

chaincodeId

Yes

String

Chaincode ID.

chaincodeVersion

No

String

Chaincode version.

userId

Yes

String

User ID issued by the organization CA. Currently, the default value generated for BCS is User1.

orgId

Yes

String

Organization ID in a blockchain.

orgPeers

Yes

String

A character string consisting of the organization ID and domain name of each peer in an organization. The format is as follows:

[{"orgId":"7258adda1803f4137eff4813e7aba323018200c5","peerDomainName":"peer-7258adda1803f4137eff4813e7aba323018200c5-0.peer-7258adda1803f4137eff4813e7aba323018200c5.default.svc.cluster.local"}]

opmethod

Yes

String

Purpose, that is, to invoke or query chaincodes.

args

Yes

String

Arguments, for example, ["Invoke", "a", "b", "1"]

timestamp

Yes

String

For example, 2018-10-31T17:28:16+08:00.

cert

Yes

String

User certificate file, which is uploaded in the form of a character string.

NOTE:

For details about how to obtain the values of the preceding parameters, see Chaincode Management and Block Browser.

  • On the Chaincode Management page, click in front of a chaincode to view its details, including the version, installation, and instantiation information.
  • On the Block Browser page, select a channel to view real-time blockchain information, including the block quantity, transaction quantity, block details, transaction details, performance, and peer statuses.
  • To ensure transaction security, you must use the private key in the Fabric user certificate (downloaded by following instructions in Downloading the User Certificate) to sign the request body. Currently, only the ECDSA encryption method is supported. Other encryption algorithms such as OSCCA-published cryptographic algorithms are not supported. Then, place the signature result in the x-bcs-signature-sign field in the request header.

Table 2 lists the request header parameters customized for the chaincode invoking RESTful API.

Table 2 Customized header parameters

Parameter

Mandatory

Description

x-bcs-signature-sign

Yes

Signature of the chaincode invoking request message body

x-bcs-signature-method

Yes

Encryption type, which is fixed at SW now.

x-bcs-signature-sign-gzip

Yes

Indication of whether GZIP compression is enabled. 0: disabled; 1: enabled.

NOTE:

x-bcs-signature-sign: To ensure that only authorized invocation entities can invoke chaincodes, the user private key (downloaded by following instructions in Downloading the User Certificate) and the ECDSA encryption method must be used to encrypt and sign the SHA256 hash of the entire request body. The value of x-bcs-signature-sign is the encrypted and signed hash.

Downloading the User Certificate

Download the user certificate that is configured in BCS to call the APIs.

  1. Log in to the Huawei Cloud BCS console.
  2. On the Instance Management page, check the BCS instances.
  3. Click Download Client Configuration, and select Peer Certificates. Specify the peer organization and select User certificate.
  4. Click Download.
  5. Decompress the certificates. In the msp folder, the private key of the organization is stored in keystore, and the user certificate (public key) in signcerts.

Response

  • If opmethod is invoke, the transactionID encrypted and encoded using Base64 is returned.
  • If opmethod is query, the query result returned by the chaincode is also encrypted and encoded using Base64.

Examples

The following is an example of invoking a chaincode:

  • Example request
    {
      "channelId": "testchannel",
      "chaincodeId": "zmmcode",
      "chaincodeVersion": "1.0",
      "userId": "User1",
      "orgId": "7258adda1803f4137eff4813e7aba323018200c5", 
      "orgPeers": "[{\"orgId\":\"7258adda1803f4137eff4813e7aba323018200c5\",\"peerDomainName\":\"peer-7258adda1803f4137eff4813e7aba323018200c5-0.peer-7258adda1803f4137eff4813e7aba323018200c5.default.svc.cluster.local\"}]",
      "opmethod": "invoke",
      "args": "[\"invoke\",\"a\",\"b\",\"1\"]",
      "timestamp": "2018-10-31T17:28:16+08:00",
      "cert": "-----BEGIN CERTIFICATE-----\nMIIDBzCCAq2gAwIBAgIQEXPZlMsReamxVtVNnKwCCzAKBggqhkjOPQQDAjCCAQQx\nDjAMBgNVBAYTBUNISU5BMRAwDgYDVQQIEwdCRUlKSU5HMRAwDgYDVQQHEwdCRUlK\nSU5HMXkwdwYDVQQKE3A3MjU4YWRkYTE4MDNmNDEzN2VmZjQ4MTNlN2FiYTMyMzAx\nODIwMGM1LnBlZXItNzI1OGFkZGExODAzZjQxMzdlZmY0ODEzZTdhYmEzMjMwMTgy\nMDBjNS5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsMVMwUQYDVQQDE0pjYS5wZWVy\nLTcyNThhZGRhMTgwM2Y0MTM3ZWZmNDgxM2U3YWJhMzIzMDE4MjAwYzUuZGVmYXVs\ndC5zdmMuY2x1c3Rlci5sb2NhbDAeFw0xODEwMzAwMjQ5MjZaFw0yODEwMjcwMjQ5\nMjZaMIG1MQ4wDAYDVQQGEwVDSElOQTEQMA4GA1UECBMHQkVJSklORzEQMA4GA1UE\nBxMHQkVJSklORzF/MH0GA1UEAwx2VXNlcjFANzI1OGFkZGExODAzZjQxMzdlZmY0\nODEzZTdhYmEzMjMwMTgyMDBjNS5wZWVyLTcyNThhZGRhMTgwM2Y0MTM3ZWZmNDgx\nM2U3YWJhMzIzMDE4MjAwYzUuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDBZMBMG\nByqGSM49AgEGCCqGSM49AwEHA0IABPMrzoJL/MHeSFPFOJWLqnJ0sqB0it7wDIOq\n+eTSvvPpGk1BIDmb2n13K5V04RO8xNezDQ7I6rW4LF2elq14eH+jTTBLMA4GA1Ud\nDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIFBXQ5TC4acFeTlT\nJuDZg62XkXCdnOfvbejSeKI2TXoIMAoGCCqGSM49BAMCA0gAMEUCIQCadHIKl0Mk\nYn0WZizyDZYR4rT2q0nzjFaiW+YfV5FBjAIgNalKUe3rIwXJvXORV4ZXurEua2Ag\nQmhcjRnVwPTjpTE=\n-----END CERTIFICATE-----\n"
    }
  • Example response
     After  invoke the count of a is 188  b is  262

Error Codes

See Error Codes.

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback