腾讯云区块链服务平台 TBaaS合约 API 列表_AI解决方案_同尘科技

腾讯云区块链服务平台TBaaS 1年前 (2023-11-20) 浏览 23

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 设置发送的事件



对腾讯云区块链服务平台 TBaaS的解决方案有疑惑?想了解解决方案收费? 联系解决方案专家

腾讯云限时活动1折起,即将结束: 马上收藏

同尘科技为腾讯云授权服务中心,购买腾讯云享受折上折,更有现金返利:同意关联,立享优惠

阿里云解决方案也看看?: 点击对比阿里云的解决方案

- 0人点赞 -

发表点评 (0条)

not found

暂无评论,你要说点什么吗?