文档

发起查询交易

更新时间:

调用链码,查询区块链账本中的数据。

API

POST:/api/v1/networks/{network}/transactions/query

Url Path 参数

描述

network

通道名称

请求参数

URL Query

URL Query 参数

类型

是否必选

描述

timeout

Integer

等待查询返回的超时时间,单位秒,默认值 180

Body

Content-Type: application/json

名称

类型

是否必选

描述

chaincode

String

调用的链码名称

args

List<String>

调用链码的参数列表,当该参数不为空时,会忽略下列 function、byte_args 两个参数

function

String

调用的链码函数名称

byte_args

List<String>

经过Base64编码的链码调用参数(不含函数名)

transient

Map<String, String>

调用链码的隐私参数字典,Key 为参数名, Value 为参数值

byte_transient

Map<String, String>

调用链码的隐私参数字典,Key 为参数名, Value 为经过Base64编码后的参数值(该参数会与 transient 合并,会覆盖 transient 中的 Key )

返回结果

名称

类型

描述

Success

Boolean

请求是否成功:

  • true:成功

  • false:失败

Error

Error

参见下表

Result

Response

参见下表

Error

名称

类型

描述

code

Integer

错误码

message

String

错误描述信息

request_id

String

请求ID

Response

名称

类型

描述

id

String

交易ID

status

String

链码(智能合约)返回的状态码,根据实际代码进行返回,通常返回 200 表示成功

event

List<Event>

交易所产生的区块链事件列表

data

String

经过Base64编码的链码返回数据

Event

名称

类型

描述

id

String

事件ID,通道内唯一

name

String

事件名称

type

EventType

事件类型(“Tx”, “Config”, “Contract”, “Block”),对于查询链上交易的接口,返回的结果只包含 “Contract”类型事件(如有)

content

String

当 EventType 为 “Contract” 时,为经过Base64编码的智能合约事件内容(如有)

示例

请求示例

curl -X POST "http://your.gateway.endpoint/api/v1/networks/channel3/transactions/query" -H "accept: application/json" -H "Authorization: Bearer <Your Access Token>" -H "Content-Type: application/json" -d "{\"chaincode\":\"sacc\",\"args\":[\"get\",\"provider\"],\"transients\":{\"key\":\"value\"}}"
说明

其中Access Token的获取方式请参见生成 Access Token;参数transients中的Key为参数名,由实际提交的数据内容决定,value是参数名对应的参数值。

正常返回示例

{
  "Success": true,
  "Result": {
    "id": "3f850796a57db7178f8e367cce736a228a8e77544ef5c92a564f9cf0ad8893c4",
    "status": "200",
    "events": [],
    "data": "YWxpeXVuMQ=="
  },
  "Error": {
    "code": 200,
    "message": "Success",
    "request_id": "5640793d-219e-4e2f-9725-988ce11ee6b6"
  }
}

错误码

请参考错误码

  • 本页导读 (0)
文档反馈