tx_getTransactions

查询指定区块区间的所有交易。

Parameters

  1. <Object>
  • from: <blockNumber> - 起始区块号。
  • to: <blockNumber> - 终止区块号。

<blockNumber>可以是十进制整数或者进制字符串,可以是“latest”字符串表示最新的区块。from必须小于等于to,否则会返回error。

Returns

  1. [<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> - 部署合约、调用合约、升级合约的时候才有这个值,可以通过这个值追溯到合约调用的方法以及调用传入的参数。

Example1: 正常的请求

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "tx_getTransactions", "params": [{"from": 1, "to": 2}], "id": 71}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace":"global",
  8. "id": 1,
  9. "result": [
  10. {
  11. "version": "1.0",
  12. "hash": "0x88d5b325dc9042ff92a9fa26ed8c943719bb049ac7022abd09bb85da36f531e4",
  13. "blockNumber": "0x2",
  14. "blockHash": "0xc6418753c28ad6d744cb4bbe689521696ba65ad010ce24056b6f8def9fc5cdd5",
  15. "txIndex": "0x0",
  16. "from": "0x000f1a7a08ccc48e5d30f80850cf1cf283aa3abd",
  17. "to": "0x0000000000000000000000000000000000000000",
  18. "amount": "0x0",
  19. "timestamp": 1486994814684628715,
  20. "nonce": 7948317390228704,
  21. "extra": "",
  22. "executeTime": "0x2",
  23. "payload": "0x60606040526000805463ffffffff19168155609e908190601e90396000f3606060405260e060020a60003504633ad14af381146030578063569c5f6d146056578063d09de08a14607c575b6002565b346002576000805463ffffffff8116600435016024350163ffffffff199091161790555b005b3460025760005463ffffffff166040805163ffffffff9092168252519081900360200190f35b3460025760546000805463ffffffff19811663ffffffff90911660010117905556"
  24. },
  25. {
  26. "version": "1.0",
  27. "hash": "0xf7149a8349f1853d8d713a15935e5059e6f55c2827f0c88f8414dd0402d6760b",
  28. "blockNumber": "0x1",
  29. "blockHash": "0x4bab3f9297e737eb197d666a2f08219f94460ace08a8e1ecad87e6e52183bcd5",
  30. "txIndex": "0x0",
  31. "from": "0x000f1a7a08ccc48e5d30f80850cf1cf283aa3abd",
  32. "to": "0x0000000000000000000000000000000000000000",
  33. "amount": "0x0",
  34. "timestamp": 1486994799163184948,
  35. "nonce": 2099818402815731,
  36. "extra": "",
  37. "executeTime": "0x7",
  38. "payload": "0x60606040526000805463ffffffff19168155609e908190601e90396000f3606060405260e060020a60003504633ad14af381146030578063569c5f6d146056578063d09de08a14607c575b6002565b346002576000805463ffffffff8116600435016024350163ffffffff199091161790555b005b3460025760005463ffffffff166040805163ffffffff9092168252519081900360200190f35b3460025760546000805463ffffffff19811663ffffffff90911660010117905556"
  39. }
  40. ]
  41. }

Example2: 区块不存在

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "tx_getTransactions", "params": [{"from": 1, "to": 2}], "id": 71}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace": "global",
  8. "id": 71,
  9. "code": -32602,
  10. "message": "block number 1 is out of range, and now latest block number is 0"
  11. }