tencent cloud

腾讯云区块链服务平台 TBaaS

产品动态
产品简介
产品概述
产品功能
底层引擎
产品优势
应用场景
基本概念
购买指南
购买页说明
欠费说明
定价与规格说明
快速入门
Hyperledger Fabric
操作指南
联盟
事件中心
网络概览
通道管理
合约管理
组织管理
节点管理
区块链浏览器
证书管理
审计日志
节点监控与日志
开发指南
Hyperledger Fabric
应用系统对接
API 文档
History
Introduction
API Category
Making API Requests
Hyperledger Fabric 2.3 APIs
Data Types
Error Codes
常见问题
产品协议
数据处理和安全协议
联系我们

合约 API 列表

PDF
聚焦模式
字号
最后更新时间: 2025-04-10 00:41:07
Fabric Go 语言版本智能合约有丰富的 API 接口,代码实现详情请参见 API 接口代码实现
从逻辑方面划分,可将 type 为 ChaincodeStub 的 API 划分为以下类型:

交易信息提取

接口
说明
GetBinding() ([]byte, error)
返回交易的 binding 信息
GetChannelID() string
获取当前的通道名称
GetCreator() ([]byte, error)
获取交易提交者信息
GetDecorations() map[string][]byte
获取交易的额外信息
GetSignedProposal() (*pb.SignedProposal, error)
获取交易提案相关数据
GetTransient() (map[string][]byte, error)
获取交易的临时信息
GetTxID() string
获取交易的交易 ID
GetTxTimestamp() (*timestamp.Timestamp, error)
获取交易时间戳

账本交互

接口
说明
PutState(key string, value []byte) error
在账本中添加或者更新一对键值
GetState(key string) ([]byte, error)
获取指定键对应的值
DelState(key string) error
在账本中,删除对应的键值
GetStateByRange(startKey, endKey string) (StateQueryIteratorInterface, error)
查询指定范围内的键值
GetStateByRangeWithPagination(startKey, endKey string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
分页查询指定范围内的键值
GetStateByPartialCompositeKey(objectType string, attributes []string) (StateQueryIteratorInterface, error)
查询匹配局部复合键的所有键值
GetStateByPartialCompositeKeyWithPagination(objectType string, keys []string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
分页查询匹配局部复合键的所有键值
GetQueryResult(query string)(StateQueryIteratorInterface, error)
查询状态数据库,需要支持富查询功能的状态数据库
GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (StateQueryIteratorInterface, *pb.QueryResponseMetadata, error)
分页查询状态数据库,需要支持富查询功能的状态数据库
GetHistoryForKey(key string) (HistoryQueryIteratorInterface, error)
返回对应键的所有历史值
SetStateValidationParameter(key string, ep []byte) error
设置特定键的背书策略
GetStateValidationParameter(key string) ([]byte, error)
获取特定键的背书策略
GetPrivateData(collection, key string) ([]byte, error)
获取指定私有数据集中的键的值
GetPrivateDataHash(collection, key string) ([]byte, error)
获取指定私有数据集中的键的值的 hash
PutPrivateData(collection string, key string, value []byte) error
设置指定私有数据集中键的值
DelPrivateData(collection, key string) error
删除指定私有数据集中对应的键
SetPrivateDataValidationParameter(collection, key string, ep []byte) error
设置指定私有数据集中键的背书策略
GetPrivateDataValidationParameter(collection, key string) ([]byte, error)
获取指定私有数据集中键的背书策略
GetPrivateDataByRange(collection, startKey, endKey string) (StateQueryIteratorInterface, error)
获取指定私有数据集中特定范围键的键值
GetPrivateDataByPartialCompositeKey(collection, objectType string, keys []string) (StateQueryIteratorInterface, error)
获取指定私有数据集中匹配局部复合键的键值
GetPrivateDataQueryResult(collection, query string) (StateQueryIteratorInterface, error)
获取指定私有数据集中特定查询的键值,需要支持富查询功能的状态数据库

参数处理

接口
说明
GetArgs() [][]byte
获取智能合约中调用参数
GetArgsSlice() ([]byte, error)
获取智能合约中调用参数
GetStringArgs() []string
获取智能合约中调用参数
GetFunctionAndParameters() (function string, params []string)
获取智能合约调用的函数名和参数, 默认第一个参数为函数名

其他辅助类

接口
说明
CreateCompositeKey(objectType string, attributes []string) (string, error)
组合属性,形成复合建
SplitCompositeKey(compositeKey string) (string, []string, error)
拆分复合键成一系列属性
InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
调用其它智能合约 Invoke 方法
SetEvent(name string, payload []byte) error
设置发送的事件


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈