block_getBatchBlocksByNumber

根据区块号列表批量查询区块详细信息。

Parameters

  1. <Object>
  • numbers: [<blockNumber>] - 要查询的区块号数组,区块号可以是十进制整数或者进制字符串,也可以是“latest”字符串表示最新的区块。
  • isPlain: <boolean> - 值为true,表示返回的区块不包括区块内的交易。值为false表示返回的区块包括区块内的交易信息。

Returns

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

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

  1. # Request
  2. curl -X POST --data ' {"jsonrpc":"2.0","method":"block_getBatchBlocksByNumber","params":[{
  3. "numbers": ["1","2"]
  4. }],"id":1}'
  5.  
  6. # Response
  7. {
  8. "jsonrpc": "2.0",
  9. "namespace": "global",
  10. "id": 1,
  11. "code": 0,
  12. "message": "SUCCESS",
  13. "result": [
  14. {
  15. "version": "1.3",
  16. "number": "0x1",
  17. "hash": "0x4cd9f393aabb2df51c09e66925c4513e23f0dbbb9e94d0351c1c3ec7539144a0",
  18. "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  19. "writeTime": 1509440821032039312,
  20. "avgTime": "0x11",
  21. "txcounts": "0x1",
  22. "merkleRoot": "0x97b0d9473478886f5b0aee123d5652b15d4ae3ab41cc487cda9d8885cb003481",
  23. "transactions": [
  24. {
  25. "version": "1.3",
  26. "hash": "0x7aebde51531bb29d3ba620f91f6e1556a1e8b50913e590f31d4fe4a2436c0602",
  27. "blockNumber": "0x1",
  28. "blockHash": "0x4cd9f393aabb2df51c09e66925c4513e23f0dbbb9e94d0351c1c3ec7539144a0",
  29. "txIndex": "0x0",
  30. "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
  31. "to": "0x0000000000000000000000000000000000000000",
  32. "amount": "0x0",
  33. "timestamp": 1509440820498000000,
  34. "nonce": 5098902950712745,
  35. "extra": "",
  36. "executeTime": "0x11",
  37. "payload": "0x6060604052341561000f57600080fd5b60405160408061016083398101604052808051919060200180519150505b6000805467ffffffff000000001963ffffffff19821663ffffffff600393840b8701840b81169190911791821664010000000092839004840b860190930b16021790555b50505b60de806100826000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630a9ae69d811460465780638466c3e614606f575b600080fd5b3415605057600080fd5b60566098565b604051600391820b90910b815260200160405180910390f35b3415607957600080fd5b605660a9565b604051600391820b90910b815260200160405180910390f35b600054640100000000900460030b81565b60005460030b815600a165627a7a7230582073eeeb74bb45b3055f1abe89f428d164ef7425bf57a999d219cbaefb6e3c0080002900000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005"
  38. }
  39. ]
  40. },
  41. {
  42. "version": "1.3",
  43. "number": "0x2",
  44. "hash": "0x9c41efcc50ec6af6e3d14e1669f37bd1fc0cfe5836af6ab1e43ced98653c938b",
  45. "parentHash": "0x4cd9f393aabb2df51c09e66925c4513e23f0dbbb9e94d0351c1c3ec7539144a0",
  46. "writeTime": 1509440823930976319,
  47. "avgTime": "0x6",
  48. "txcounts": "0x1",
  49. "merkleRoot": "0x97b0d9473478886f5b0aee123d5652b15d4ae3ab41cc487cda9d8885cb003481",
  50. "transactions": [
  51. {
  52. "version": "1.3",
  53. "hash": "0x22321358931c577ceaa2088d914758148dc6c1b6096a0b3f565d130f03ca75e4",
  54. "blockNumber": "0x2",
  55. "blockHash": "0x9c41efcc50ec6af6e3d14e1669f37bd1fc0cfe5836af6ab1e43ced98653c938b",
  56. "txIndex": "0x0",
  57. "from": "0x17d806c92fa941b4b7a8ffffc58fa2f297a3bffc",
  58. "to": "0xaeccd2fd1118334402c5de1cb014a9c192c498df",
  59. "amount": "0x0",
  60. "timestamp": 1509440823410000000,
  61. "nonce": 8291834415403909,
  62. "extra": "",
  63. "executeTime": "0x6",
  64. "payload": "0x0a9ae69d"
  65. }
  66. ]
  67. }
  68. ]
  69. }

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

  1. # Request
  2. curl -X POST --data ' {"jsonrpc":"2.0","method":"block_getBatchBlocksByNumber","params":[{
  3. "numbers": ["1","2"],
  4. "isPlain": true
  5. }],"id":1}'
  6.  
  7. # Response
  8. {
  9. "jsonrpc": "2.0",
  10. "namespace": "global",
  11. "id": 1,
  12. "code": 0,
  13. "message": "SUCCESS",
  14. "result": [
  15. {
  16. "version": "1.3",
  17. "number": "0x1",
  18. "hash": "0x4cd9f393aabb2df51c09e66925c4513e23f0dbbb9e94d0351c1c3ec7539144a0",
  19. "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  20. "writeTime": 1509440821032039312,
  21. "avgTime": "0x11",
  22. "txcounts": "0x1",
  23. "merkleRoot": "0x97b0d9473478886f5b0aee123d5652b15d4ae3ab41cc487cda9d8885cb003481"
  24. },
  25. {
  26. "version": "1.3",
  27. "number": "0x2",
  28. "hash": "0x9c41efcc50ec6af6e3d14e1669f37bd1fc0cfe5836af6ab1e43ced98653c938b",
  29. "parentHash": "0x4cd9f393aabb2df51c09e66925c4513e23f0dbbb9e94d0351c1c3ec7539144a0",
  30. "writeTime": 1509440823930976319,
  31. "avgTime": "0x6",
  32. "txcounts": "0x1",
  33. "merkleRoot": "0x97b0d9473478886f5b0aee123d5652b15d4ae3ab41cc487cda9d8885cb003481"
  34. }
  35. ]
  36. }