腾讯云区块链服务平台 TBaaS合约 API 列表_AI解决方案_同尘科技
ChainMaker C++ 语言版本智能合约有丰富的 API 接口,供用户在撰写智能合约的时候与链进行交互,代码实现详情可以参考API 接口代码实现。从逻辑方面划分,可将 API 划分为以下类型:
账本交互
接口 | 说明 |
bool get_object(const std::string& key, std::string* value){} | 获取key为”key”的值。 |
bool put_object(const std::string& key, const std::string& value){} | 存储key为”key”的值,注意key长度不允许超过64,且只允许大小写字母、数字、下划线、减号、小数点符号。 |
bool delete_object(const std::string& key) {} | 删除key为”key”的值。 |
bool call(const std::string &contract, const std::string &method, EasyCodecItems *args, std::string *resp){} | 跨合约调用。 |
参数处理
接口 | 说明 |
bool arg(const std::string& name, std::string& value){} | 该接口可返回属性名为 “name” 的参数的属性值。需要注意的是通过arg接口返回的参数,全部为字符串,合约开发者有必要将其他数据类型的参数与字符串做转换,包括atoi、itoa、自定义序列化方式等。 |
其他辅助类
接口 | 说明 |
void success(const std::string& body) {} | 返回成功的结果 |
void error(const std::string& body) {} | 返回失败结果 |
void log(const std::string& body) {} | 输出日志事件。查看方式为在链配置的log.yml中,开启vm:debug即可看到类似:wxvm log>> + msg |
bool emit_event(const std::string &topic, int data_amount, const std::string data, …) | 发送合约事件 |
对腾讯云区块链服务平台 TBaaS的解决方案有疑惑?想了解解决方案收费? 联系解决方案专家
腾讯云限时活动1折起,即将结束: 马上收藏
同尘科技为腾讯云授权服务中心,购买腾讯云享受折上折,更有现金返利:同意关联,立享优惠
阿里云解决方案也看看?: 点击对比阿里云的解决方案
暂无评论,你要说点什么吗?