Block - 获取指定区块数据
block
接口用来获取指定高度的区块。如果未指定区块高度,该调用将返回最新区块。
API请求
GET /block
查询参数:
-height:要查询的区块的高度,int64,可选,默认值:0,表示最新区块
API响应
返回JSON对象,结构如下:
- jsonrpc:JSONRPC版本,固定为"2.0"
- id:API请求的ID编号
- error:错误描述信息
- result:应用信息结果
- block:区块对象,结构如下:
- last_commits:最近提交对象,结果如下:
- precommits:预提交数组
- blockID:区块ID
- data:区块数据对象,结构如下:
- txs:交易数组
- header:区块头对象,结构如下:
- app_hash:应用哈希
- chain_id:链ID
- height:区块高度
- time:时间戳
- num_txs:交易数量
- last_block_id:前区块ID
- last_commit_hash:最近提交哈希
- data_hash:数据哈希
- validators_hash:验证节点哈希
- last_commits:最近提交对象,结果如下:
- block_meta:区块元数据对象,结构如下:
- header:头对象
- block_id:区块ID
- block:区块对象,结构如下:
示例代码
使用curl调用Block接口,获取高度为10的区块数据:
~$ curl 'localhost:26657/block?height=10'
响应结果:
{
"error": "",
"result": {
"block": {
"last_commit": {
"precommits": [
{
"signature": {
"data": "12C0D8893B8A38224488DC1DE6270DF76BB1A5E9DB1C68577706A6A97C6EC34FFD12339183D5CA8BC2F46148773823DE905B7F6F5862FD564038BB7AE03BF50D",
"type": "ed25519"
},
"block_id": {
"parts": {
"hash": "3C78F00658E06744A88F24FF97A0A5011139F34A",
"total": "1"
},
"hash": "F70588DAB36BDA5A953D548A16F7D48C6C2DFD78"
},
"type": "2",
"round": "0",
"height": "9",
"validator_index": "0",
"validator_address": "E89A51D60F68385E09E716D353373B11F8FACD62"
}
],
"blockID": {
"parts": {
"hash": "3C78F00658E06744A88F24FF97A0A5011139F34A",
"total": "1"
},
"hash": "F70588DAB36BDA5A953D548A16F7D48C6C2DFD78"
}
},
"data": {
"txs": []
},
"header": {
"app_hash": "",
"chain_id": "test-chain-6UTNIN",
"height": "10",
"time": "2017-05-29T15:05:53.877Z",
"num_txs": "0",
"last_block_id": {
"parts": {
"hash": "3C78F00658E06744A88F24FF97A0A5011139F34A",
"total": "1"
},
"hash": "F70588DAB36BDA5A953D548A16F7D48C6C2DFD78"
},
"last_commit_hash": "F31CC4282E50B3F2A58D763D233D76F26D26CABE",
"data_hash": "",
"validators_hash": "9365FC80F234C967BD233F5A3E2AB2F1E4B0E5AA"
}
},
"block_meta": {
"header": {
"app_hash": "",
"chain_id": "test-chain-6UTNIN",
"height": "10",
"time": "2017-05-29T15:05:53.877Z",
"num_txs": "0",
"last_block_id": {
"parts": {
"hash": "3C78F00658E06744A88F24FF97A0A5011139F34A",
"total": "1"
},
"hash": "F70588DAB36BDA5A953D548A16F7D48C6C2DFD78"
},
"last_commit_hash": "F31CC4282E50B3F2A58D763D233D76F26D26CABE",
"data_hash": "",
"validators_hash": "9365FC80F234C967BD233F5A3E2AB2F1E4B0E5AA"
},
"block_id": {
"parts": {
"hash": "277A4DBEF91483A18B85F2F5677ABF9694DFA40F",
"total": "1"
},
"hash": "96B1D2F2D201BA4BC383EB8224139DB1294944E5"
}
}
},
"id": "",
"jsonrpc": "2.0"
}