tx_getTransactionByHash
根据交易哈希查询交易详情。
Parameters
<string>
- 32字节的十六进制字符串,交易的哈希值。
Returns
<Transaction>
- Transaction对象字段如下:
version
:<string>
- 平台版本号。hash
:<string>
- 32字节的十六进制字符串,交易哈希值。blockNumber
:<string>
- 十六进制,交易所在区块的高度。blockHash
:<string>
- 32字节的十六进制字符串,交易所在区块的哈希。txIndex
:<string>
- 十六进制,交易在区块中的偏移量。from
:<string>
- 20字节的十六进制字符串,交易发送方的地址。to
:<string>
- 20字节的十六进制字符串,交易接收方的地址。amount
:<string>
- 转账金额。timestamp
:<number>
- 交易发生的unix时间戳(单位ns)。nonce
:<number>
- 16位随机数。extra
:<string>
- 交易的额外信息。executeTime
:<string>
- 交易的处理时间(单位ms)。payload
:<string>
- 部署合约、调用合约、升级合约的时候才有这个值,可以通过这个值追溯到合约调用的方法以及调用传入的参数。invalid
:<boolean>
- 交易是否不合法。invalidMsg
:<string>
- 交易的不合法信息。
不合法的交易invalid
值为true, invalidMsg
可能为:
- OUTOFBALANCE - 余额不足,对应code是-32002;
- SIGFAILED - 签名非法,对应code是-32003;
- DEPLOY_CONTRACT_FAILED - 合约部署失败,对应code是-32004;
- INVOKE_CONTRACT_FAILED - 合约方法调用失败,对应code是-32005;
- INVALID_PERMISSION - 合约操作权限不够,对应code是-32008;
Example1:查询合法的交易
- # Request
- curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method":"tx_getTransactionByHash", "params":["0xe652e25e617c5f193b240c0d8ff1941a8cfb1d15434eb3830892b7a8389730aa"], "id": 1}'
- # Response
- {
- "jsonrpc": "2.0",
- "namespace":"global",
- "id": 1,
- "code": 0,
- "message": "SUCCESS",
- "result": {
- "version": "1.0",
- "hash": "0xe652e25e617c5f193b240c0d8ff1941a8cfb1d15434eb3830892b7a8389730aa",
- "blockNumber": "0x4",
- "blockHash": "0x6ea0c80c1532c273c124511e364fc0a9225e0d129e53249f8e26752ee7d7d989",
- "txIndex": "0x0",
- "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
- "to": "0x0000000000000000000000000000000000000000",
- "amount": "0x0",
- "timestamp": 1482405601747000000,
- "nonce": 6788653222523786,
- "extra": "",
- "executeTime": "0x2",
- "payload": "0x606060405260008055602d8060146000396000f3606060405260e060020a6000350463be1c766b8114601c575b6002565b34600257600060026000908155600256"
- }
- }
Example2:查询非法的交易
- # Request
- curl -X POST --data '{"jsonrpc":"2.0","method":"tx_getTransactionByHash","params":["0x1f6dc4c744ce5e8a39e6a19f19dc27c99d7efd8e38061e80550bf5e7ab1060e1"],"id":1}'
- # Response
- {
- "jsonrpc": "2.0",
- "namespace": "global",
- "id": 1,
- "code": 0,
- "message": "SUCCESS",
- "result": {
- "version": "1.3",
- "hash": "0x1f6dc4c744ce5e8a39e6a19f19dc27c99d7efd8e38061e80550bf5e7ab1060e1",
- "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
- "to": "0x0000000000000000000000000000000000000000",
- "amount": "0x0",
- "timestamp": 1509448178302000000,
- "nonce": 1166705097783423,
- "extra": "",
- "payload": "0x6060604052600080553415601257600080fd5b5b6002600090815580fd5b5b5b60918061002d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663be1c766b8114603c575b600080fd5b3415604657600080fd5b604c605e565b60405190815260200160405180910390f35b6000545b905600a165627a7a723058201e24ee668219357c2daa85cc0d2b3b31c192431783315ea37ed69c9e80a100e90029",
- "invalid": true,
- "invalidMsg": "DEPLOY_CONTRACT_FAILED"
- }
- }
Example3:查询的交易不存在
- # Request
- curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method":"tx_getTransactionByHash", "params":[" 0x0e707231fd779779ce25a06f51aec60faed8bf6907e6d74fb11a3fd585831a7e"], "id": 1}'
- # Response
- {
- "jsonrpc": "2.0",
- "namespace": "global",
- "id": 1,
- "code": -32001,
- "message": "Not found transaction 0x0e707231fd779779ce25a06f51aec60faed8bf6907e6d74fb11a3fd585831a7e"
- }
当前内容版权归 Hyperchain 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Hyperchain .