查询交易信息

向区块链网络查询某一交易的信息。

API

GET /api/v1/networks/{network}/transactions/{id}

Url Path 参数 描述
network 通道名称
id 交易ID

返回结果

名称 类型 描述
Success Boolean 请求是否成功
Error Error -
Result Transaction -

Error

名称 类型 描述
code Integer 错误码
message String 错误描述信息
request_id String 请求ID

Transaction

名称 类型 描述
id String 交易ID
state String 交易状态,”VALID” 表示合法交易,其它值表示非法交易
from String 交易的发起者,格式为 <组织MSP>.<用户名>
to String 交易调用的目标链码名称
input String 经过 Json 编码的链码调用参数
events List<Event> 交易所产生的区块链事件列表
data Object 交易的详细内容,数据结构为交易中的 common.Payload

Event

名称 类型 描述
id String 事件ID,通道内唯一
name String 事件名称
type EventType 事件类型(“Tx”, “Config”, “Contract”, “Block”),该接口返回的结果只包含 “Contract”类型事件(如有)
content String 当 EventType 为 “Contract” 时,为经过Base64编码的智能合约事件内容(如有)

示例

请求示例

  1. curl -X GET "http://your.gateway.endpoint/api/v1/networks/channel3/transactions/e49d411a2ff32caa1688b5e0a07a957d2d8a4c8c124554772d07145214b3ba13" -H "accept: application/json" -H "Authorization: Bearer <Your Access Token>"

正常返回示例

  1. {
  2. "Success": true,
  3. "Result": {
  4. "id": "e49d411a2ff32caa1688b5e0a07a957d2d8a4c8c124554772d07145214b3ba13",
  5. "state": "VALID",
  6. "from": "e2ehmfqasthMSP.octopus_26842_12345678901234",
  7. "to": "sacc",
  8. "input": "[\"set\",\"provider\",\"aliyun3\"]",
  9. "events": null,
  10. "data": {
  11. "data": {
  12. "actions": [
  13. {
  14. "header": {
  15. "creator": {
  16. "id_bytes": "LS0tLS1CR...SUZJQ0FURS0tLS0tCg==",
  17. "mspid": "e2ehmfqasthMSP"
  18. },
  19. "nonce": "HdQ823siiR5yzRq/sGkrD0y6jTMOVkuG"
  20. },
  21. "payload": {
  22. "action": {
  23. "endorsements": [
  24. {
  25. "endorser": "Cg5lMmVobW...S0tLS0tCg==",
  26. "signature": "MEQCIHm9YG6PbIUpqa3DF6l6h5vRTQxbGVyWkiYqOAIX5pa2AiBFQNvTfzlf951oj/ki0eGbB0AV9fGwBA8TpXMhyoGdgg=="
  27. }
  28. ],
  29. "proposal_response_payload": {
  30. "extension": {
  31. "chaincode_id": {
  32. "name": "sacc",
  33. "path": "",
  34. "version": "3.0"
  35. },
  36. "events": null,
  37. "response": {
  38. "message": "",
  39. "payload": "YWxpeXVuMw==",
  40. "status": 200
  41. },
  42. "results": {
  43. "data_model": "KV",
  44. "ns_rwset": [
  45. {
  46. "collection_hashed_rwset": [],
  47. "namespace": "lscc",
  48. "rwset": {
  49. "metadata_writes": [],
  50. "range_queries_info": [],
  51. "reads": [
  52. {
  53. "key": "sacc",
  54. "version": {
  55. "block_num": "16",
  56. "tx_num": "0"
  57. }
  58. }
  59. ],
  60. "writes": []
  61. }
  62. },
  63. {
  64. "collection_hashed_rwset": [],
  65. "namespace": "sacc",
  66. "rwset": {
  67. "metadata_writes": [],
  68. "range_queries_info": [],
  69. "reads": [],
  70. "writes": [
  71. {
  72. "is_delete": false,
  73. "key": "provider",
  74. "value": "YWxpeXVuMw=="
  75. }
  76. ]
  77. }
  78. }
  79. ]
  80. }
  81. },
  82. "proposal_hash": "dEy87BXYByKTxVjk2A0XMViX402pbHQOjAq/Y6i0XG0="
  83. }
  84. },
  85. "chaincode_proposal_payload": {
  86. "TransientMap": {},
  87. "input": {
  88. "chaincode_spec": {
  89. "chaincode_id": {
  90. "name": "sacc",
  91. "path": "",
  92. "version": ""
  93. },
  94. "input": {
  95. "args": [
  96. "c2V0",
  97. "cHJvdmlkZXI=",
  98. "YWxpeXVuMw=="
  99. ],
  100. "decorations": {},
  101. "is_init": false
  102. },
  103. "timeout": 0,
  104. "type": "GOLANG"
  105. }
  106. }
  107. }
  108. }
  109. }
  110. ]
  111. },
  112. "header": {
  113. "channel_header": {
  114. "channel_id": "channel3",
  115. "epoch": "0",
  116. "extension": "EgYSBHNhY2M=",
  117. "timestamp": "2020-02-13T08:09:31.588293471Z",
  118. "tls_cert_hash": null,
  119. "tx_id": "e49d411a2ff32caa1688b5e0a07a957d2d8a4c8c124554772d07145214b3ba13",
  120. "type": 3,
  121. "version": 0
  122. },
  123. "signature_header": {
  124. "creator": {
  125. "id_bytes": "LS0tLS1CR...0FURS0tLS0tCg==",
  126. "mspid": "e2ehmfqasthMSP"
  127. },
  128. "nonce": "HdQ823siiR5yzRq/sGkrD0y6jTMOVkuG"
  129. }
  130. }
  131. }
  132. },
  133. "Error": {
  134. "code": 200,
  135. "message": "Success",
  136. "request_id": "759fb8ee-9763-4355-b742-becc81cb7bf5"
  137. }
  138. }

错误码

请参考错误码