tencent cloud

Contract API List

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-04-10 00:41:07
The smart contract in Fabric's Go language version has various API interfaces. For details on the code implementation, see API Interface Code Implementation.
Divided from the logic aspect, the APIs with the type of ChaincodeStub can be divided into following types:

Transaction Information Extraction

API
Description
GetBinding() ([]byte, error)
Return binding Information of the Transaction
GetChannelID() string
Get the current channel name.
GetCreator() ([]byte, error)
Get the information of the transaction submitter.
GetDecorations() map[string][]byte
Get additional information of the transaction
GetSignedProposal() (*pb.SignedProposal, error)
Retrieve related data of the transaction proposal.
GetTransient() (map[string][]byte, error)
Retrieve temporary information of the transaction
GetTxID() string
Retrieve the transaction ID of a transaction
GetTxTimestamp() (*timestamp.Timestamp, error)
Retrieve the transaction timestamp

Ledger Interaction

API
Description
PutState(key string, value []byte) error
Add or update a key-value pair in the ledger
GetState(key string) ([]byte, error)
Retrieve the value corresponding to the specified key.
DelState(key string) error
Delete the corresponding key-value in the ledger.
GetStateByRange(startKey, endKey string) (StateQueryIteratorInterface, error)
Query the key-value pairs in the specified range.
GetStateByRangeWithPagination(startKey, endKey string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
Paging Query for Key-Value Pairs within the Specified Range
GetStateByPartialCompositeKey(objectType string, attributes []string) (StateQueryIteratorInterface, error)
Query all key-values for partial composite key matching.
GetStateByPartialCompositeKeyWithPagination(objectType string, keys []string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
Paging query for all key-values matching partial composite key
GetQueryResult(query string)(StateQueryIteratorInterface, error)
Inquire state database, state database that requires support for rich query feature.
GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
Paging query state database, state database that requires support for rich query feature.
GetHistoryForKey(key string) (HistoryQueryIteratorInterface, error)
Return all historical values of the corresponding key
SetStateValidationParameter(key string, ep []byte) error
Set the endorsement policy for a specific key
GetStateValidationParameter(key string) ([]byte, error)
Retrieve the endorsement policy for a specific key
GetPrivateData(collection, key string) ([]byte, error)
Retrieve the value of the key in the specified private data set.
GetPrivateDataHash(collection, key string) ([]byte, error)
Retrieve the hash of the value of the key in the specified private data set.
PutPrivateData(collection string, key string, value []byte) error
Set the value of the key in the specified private data set.
DelPrivateData(collection, key string) error
Delete the corresponding key in the specified private data set.
SetPrivateDataValidationParameter(collection, key string, ep []byte) error
Set the endorsement policy of the key in the specified private data set.
GetPrivateDataValidationParameter(collection, key string) ([]byte, error)
Retrieve the endorsement policy of the key in the specified private data set.
GetPrivateDataByRange(collection, startKey, endKey string) (StateQueryIteratorInterface, error)
Retrieve the key-values of keys in the specific range in the specified private data set.
GetPrivateDataByPartialCompositeKey(collection, objectType string, keys []string) (StateQueryIteratorInterface, error)
Retrieve the key-values of keys that match the partial composite key in the specified private data set.
GetPrivateDataQueryResult(collection, query string) (StateQueryIteratorInterface, error)
Retrieve the key-values of specific queries in the specified private data set, state database that requires support for rich query feature.

Parameter Handling

API
Description
GetArgs() [][]byte
Get the calling parameters in the smart contract.
GetArgsSlice() ([]byte, error)
Retrieve the calling parameters in the smart contract.
GetStringArgs() []string
Get the calling parameters in the smart contract.
GetFunctionAndParameters() (function string, params []string)
Retrieve the function name and parameters called by the smart contract, with the first parameter being the function name by default.

Other Auxiliary Classes

API
Description
CreateCompositeKey(objectType string, attributes []string) (string, error)
Composite attributes form a composite key.
SplitCompositeKey(compositeKey string) (string, []string, error)
Split the composite key into a series of attributes.
InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
Call the Invoke method of other smart contracts.
SetEvent(name string, payload []byte) error
Set Sent Events


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백