block_getBlocks

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

Parameters

  1. <Object>
  • from: <blockNumber> - 起始区块号。
  • to: <blockNumber> - 终止区块号。
  • isPlain: <boolean> - [可选] 默认值为false,表示返回的区块包括区块内的交易信息,如果指定为true,表示返回的区块不包括区块内的交易。

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

Returns

  1. [<Block>] - Block对象字段见 Block.

Example1:返回的区块包括交易信息

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "block_getBlocks", "params": [{"from":2,"to":3}], "id": 1}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace":"global",
  8. "id": 1,
  9. "code": 0,
  10. "message": "SUCCESS",
  11. "result": [
  12. {
  13. "version": "1.0",
  14. "number": "0x3",
  15. "hash": "0x00acc3e13d8124fe799d55d7d2af06223148dc7bbc723718bb1a88fead34c914",
  16. "parentHash": "0x2b709670922de0dda68926f96cffbe48c980c4325d416dab62b4be27fd73cee9",
  17. "writeTime": 1481778653997475900,
  18. "avgTime": "0x2",
  19. "txcounts": "0x1",
  20. "merkleRoot": "0xc6fb0054aa90f3bfc78fe79cc459f7c7f268af7eef23bd4d8fc85204cb00ab6c",
  21. "transactions": [
  22. {
  23. "version": "1.0",
  24. "hash": "0xf57a6443d08cda4a3dfb8083804b6334d17d7af51c94a5f98ed67179b59169ae",
  25. "blockNumber": "0x3",
  26. "blockHash": "0x00acc3e13d8124fe799d55d7d2af06223148dc7bbc723718bb1a88fead34c914",
  27. "txIndex": "0x0",
  28. "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
  29. "to": "0xaeccd2fd1118334402c5de1cb014a9c192c498df",
  30. "amount": "0x0",
  31. "timestamp": 1481778652973000000,
  32. "nonce": 3573634504790373,
  33. "extra": "",
  34. "executeTime": "0x2",
  35. "payload": "0x81053a70000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001c8"
  36. }
  37. ]
  38. },
  39. {
  40. "version": "1.0",
  41. "number": "0x2",
  42. "hash": "0x2b709670922de0dda68926f96cffbe48c980c4325d416dab62b4be27fd73cee9",
  43. "parentHash": "0xe287c62aae77462aa772bd68da9f1a1ba21a0d044e2cc47f742409c20643e50c",
  44. "writeTime": 1481778642328872960,
  45. "avgTime": "0x2",
  46. "txcounts": "0x1",
  47. "merkleRoot": "0xc6fb0054aa90f3bfc78fe79cc459f7c7f268af7eef23bd4d8fc85204cb00ab6c",
  48. "transactions": [
  49. {
  50. "version": "1.0",
  51. "hash": "0x07d606a25d1eab009f5374950383e9c0697599e6c35999337b969ba356800168",
  52. "blockNumber": "0x2",
  53. "blockHash": "0x2b709670922de0dda68926f96cffbe48c980c4325d416dab62b4be27fd73cee9",
  54. "txIndex": "0x0",
  55. "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
  56. "to": "0xaeccd2fd1118334402c5de1cb014a9c192c498df",
  57. "amount": "0x0",
  58. "timestamp": 1481778641306000000,
  59. "nonce": 1628827117185765,
  60. "extra": "",
  61. "executeTime": "0x2",
  62. "payload": "0x6fd7cc16000000000000000000000000000000000000000000000000000000000000303a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  63. }
  64. ]
  65. }
  66. ]
  67. }

Example2:返回的区块不包括交易信息

  1. # Request
  2. curl -X POST --data '{"jsonrpc": "2.0", "namespace":"global", "method": "block_getBlocks", "params": [{"from":2,"to":3,"isPlain":true}], "id": 1}'
  3.  
  4. # Response
  5. {
  6. "jsonrpc": "2.0",
  7. "namespace":"global",
  8. "id": 1,
  9. "code": 0,
  10. "message": "SUCCESS",
  11. "result": [
  12. {
  13. "version": "1.0",
  14. "number": "0x3",
  15. "hash": "0x00acc3e13d8124fe799d55d7d2af06223148dc7bbc723718bb1a88fead34c914",
  16. "parentHash": "0x2b709670922de0dda68926f96cffbe48c980c4325d416dab62b4be27fd73cee9",
  17. "writeTime": 1481778653997475900,
  18. "avgTime": "0x2",
  19. "txcounts": "0x1",
  20. "merkleRoot": "0xc6fb0054aa90f3bfc78fe79cc459f7c7f268af7eef23bd4d8fc85204cb00ab6c"
  21. },
  22. {
  23. "version": "1.0",
  24. "number": "0x2",
  25. "hash": "0x2b709670922de0dda68926f96cffbe48c980c4325d416dab62b4be27fd73cee9",
  26. "parentHash": "0xe287c62aae77462aa772bd68da9f1a1ba21a0d044e2cc47f742409c20643e50c",
  27. "writeTime": 1481778642328872960,
  28. "avgTime": "0x2",
  29. "txcounts": "0x1",
  30. "merkleRoot": "0xc6fb0054aa90f3bfc78fe79cc459f7c7f268af7eef23bd4d8fc85204cb00ab6c"
  31. }
  32. ]
  33. }