tx_getTransactionByBlockHashAndIndex

根据区块哈希和交易偏移量查询交易。

Parameters

  1. <string> - 32字节的十六进制字符串,区块的哈希值。
  2. <number> - 交易在区块中的偏移量,可以是十进制整数或进制字符串。

Returns

  1. <Transaction> - Transaction对象字段见 合法交易.

Example1:正常的请求

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "tx_getTransactionsByBlockHashAndIndex","params": ["0xd198976fa8b4ca2de6b1b137552b84dc08b7cdcbebbf9388add88f4710fd2cf9", 0], "id": 71}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace":"global",
  8. "id": 1,
  9. "code": 0,
  10. "message": "SUCCESS",
  11. "result": {
  12. "version": "1.0",
  13. "hash": "0xe81d39df11779c7f83e6073cc659c7ee85708c135b6557d318e765b9f938c02f",
  14. "blockNumber": "0x2",
  15. "blockHash": "0xd198976fa8b4ca2de6b1b137552b84dc08b7cdcbebbf9388add88f4710fd2cf9",
  16. "txIndex": "0x0",
  17. "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
  18. "to": "0x3a3cae27d1b9fa931458b5b2a5247c5d67c75d61",
  19. "amount": "0x0",
  20. "timestamp": 1481767474717000000,
  21. "nonce": 8054165127693853,
  22. "extra": "",
  23. "executeTime": "0x2",
  24. "payload": "0x6fd7cc16000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  25. }
  26. }

Example2:查询的区块不存在

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "tx_getTransactionsByBlockHashAndIndex","params": ["0xd198976fa8b4ca2de6b1b137552b84dc08b7cdcbebbf9388add88f4710fd2cf9", 0], "id": 71}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace": "global",
  8. "id": 71,
  9. "code": -32001,
  10. "message": "Not found block 0xd198976fa8b4ca2de6b1b137552b84dc08b7cdcbebbf9388add88f4710fd2cf9"
  11. }