tendermint提供的RPC接口(二)
四,Info
/health
说明:获取节点心跳,返回空为正常
示例:
C:\Users\ch>curl -s localhost:26657/health
{
"jsonrpc": "2.0",
"id": "",
"result": {}
}
/status
说明:获取节点信息
包括节点信息,公钥,最新区块hash,区块高度等等
示例:
C:\Users\ch>curl -s localhost:26657/status
{
"jsonrpc": "2.0",
"id": "",
"result": {
"node_info": {
"protocol_version": {
"p2p": "7",
"block": "10",
"app": "1"
},
"id": "fe807a7617494c46d38bc040801ab567cc330852",
"listen_addr": "tcp://0.0.0.0:26656",
"network": "test-chain-17UaI5",
"version": "0.32.1",
"channels": "4020212223303800",
"moniker": "caohuan",
"other": {
"tx_index": "on",
"rpc_address": "tcp://127.0.0.1:26657"
}
},
"sync_info": {
"latest_block_hash": "2211B8262B6246EF236DBBB641E056E5A664F0FF821428C8E4B8FBDB231DBA63",
"latest_app_hash": "1400000000000000",
"latest_block_height": "13",
"latest_block_time": "2019-09-09T07:38:35.0507361Z",
"catching_up": false
},
"validator_info": {
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10"
}
}
}
/net_info
说明:获取网络信息
示例:
C:\Users\ch>curl -s localhost:26657/net_info
{
"jsonrpc": "2.0",
"id": "",
"result": {
"listening": true,
"listeners": [
"Listener(@)"
],
"n_peers": "0",
"peers": []
}
}
/blockchain
说明:获取区块信息
传入开始区块(minHeight)和截止区块(maxHeight)两个参数
示例:
C:\Users\ch>curl -s "localhost:26657/blockchain?minHeight=4&maxHeight=5"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"last_height": "13",
"block_metas": [
{
"block_id": {
"hash": "6EF5FDE1482DD6CE24647DF998A8B5E7E7609307B2534309B10CA035BE7D7171",
"parts": {
"total": "1",
"hash": "FF04D0225B8A0B43A019AC0C136C1D71A08B683ADD47FD0B324C93BC86A4D3A8"
}
},
"header": {
"version": {
"block": "10",
"app": "1"
},
"chain_id": "test-chain-17UaI5",
"height": "5",
"time": "2019-09-09T07:38:27.0507361Z",
"num_txs": "1",
"total_txs": "3",
"last_block_id": {
"hash": "61D7CDDE0B3280661BF2736A29AD7C38EC4860A4F080D4D840B11D3B9E2C1781",
"parts": {
"total": "1",
"hash": "D0657ECD49F0946326A4E26977C4FC8E4606FD805315F5CEB666F45688C6B170"
}
},
"last_commit_hash": "8136B24934FAF6DC6B94AC8E210AA18E09DEB35B9984B72EFB4674546838A449",
"data_hash": "9ECB7139BD0145C32047E358F4D2EA9B6CEA94DBD6B429427CB70BC93115BA9F",
"validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"next_validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
"app_hash": "0400000000000000",
"last_results_hash": "6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D",
"evidence_hash": "",
"proposer_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607"
}
},
{
"block_id": {
"hash": "61D7CDDE0B3280661BF2736A29AD7C38EC4860A4F080D4D840B11D3B9E2C1781",
"parts": {
"total": "1",
"hash": "D0657ECD49F0946326A4E26977C4FC8E4606FD805315F5CEB666F45688C6B170"
}
},
"header": {
"version": {
"block": "10",
"app": "1"
},
"chain_id": "test-chain-17UaI5",
"height": "4",
"time": "2019-09-09T07:38:26.0507361Z",
"num_txs": "1",
"total_txs": "2",
"last_block_id": {
"hash": "97E69293BDE1207223E1A4AE41E078BACCB0615630B66DD93F32EC6CA4BE1F9F",
"parts": {
"total": "1",
"hash": "48EC83BBD54C6BA29BCF4B09FDF265C324F0F9E949233320D37A223AB0E22096"
}
},
"last_commit_hash": "4297ED68980EA06477F95024EE172D8F663E7350BF24A98C5CDD059FD03BF136",
"data_hash": "94566C8B476C6BD469632EB5E95F756EE21516A2C8ABA09710C7860529F0B19F",
"validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"next_validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
"app_hash": "0200000000000000",
"last_results_hash": "6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D",
"evidence_hash": "",
"proposer_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607"
}
}
]
}
}
/block
说明:获取某个具体的区块信息
参数height表示区块高度,不传或者传0时,默认为最新的区块高度
示例:
C:\Users\ch>curl -s "localhost:26657/block?height=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"block_meta": {
"block_id": {
"hash": "31FB364FFDC92C8EC5F63FE54E430D2996A31D3A3DBA416B3D17E13A76C5A300",
"parts": {
"total": "1",
"hash": "897CB6F0FEC7DCCFB1BD84933CBACA2064FEB8659925E7252F3AD8054BA1C655"
}
},
"header": {
"version": {
"block": "10",
"app": "1"
},
"chain_id": "test-chain-17UaI5",
"height": "10",
"time": "2019-09-09T07:38:32.0507361Z",
"num_txs": "1",
"total_txs": "8",
"last_block_id": {
"hash": "C781443961064AB326D14105C0B4AA31F80772EE9824D8962AF92993557A4AE4",
"parts": {
"total": "1",
"hash": "CE457673AAFC5332A11C9DA2E3CD98652F85D1983C23E3016C9704DD004E4188"
}
},
"last_commit_hash": "326DB19B9B3D90464C31EF70BF8CC892944C719DF2CC586944A047DD76D0C7E0",
"data_hash": "9EE9AE5B6BE62129743563FB35B1BC7FB28E1217D551B5F3BC087F811A44F7C5",
"validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"next_validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
"app_hash": "0E00000000000000",
"last_results_hash": "6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D",
"evidence_hash": "",
"proposer_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607"
}
},
"block": {
"header": {
"version": {
"block": "10",
"app": "1"
},
"chain_id": "test-chain-17UaI5",
"height": "10",
"time": "2019-09-09T07:38:32.0507361Z",
"num_txs": "1",
"total_txs": "8",
"last_block_id": {
"hash": "C781443961064AB326D14105C0B4AA31F80772EE9824D8962AF92993557A4AE4",
"parts": {
"total": "1",
"hash": "CE457673AAFC5332A11C9DA2E3CD98652F85D1983C23E3016C9704DD004E4188"
}
},
"last_commit_hash": "326DB19B9B3D90464C31EF70BF8CC892944C719DF2CC586944A047DD76D0C7E0",
"data_hash": "9EE9AE5B6BE62129743563FB35B1BC7FB28E1217D551B5F3BC087F811A44F7C5",
"validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"next_validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
"app_hash": "0E00000000000000",
"last_results_hash": "6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D",
"evidence_hash": "",
"proposer_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607"
},
"data": {
"txs": [
"YXV0aG9yNz1jYW9odWFuNw=="
]
},
"evidence": {
"evidence": null
},
"last_commit": {
"block_id": {
"hash": "C781443961064AB326D14105C0B4AA31F80772EE9824D8962AF92993557A4AE4",
"parts": {
"total": "1",
"hash": "CE457673AAFC5332A11C9DA2E3CD98652F85D1983C23E3016C9704DD004E4188"
}
},
"precommits": [
{
"type": 2,
"height": "9",
"round": "0",
"block_id": {
"hash": "C781443961064AB326D14105C0B4AA31F80772EE9824D8962AF92993557A4AE4",
"parts": {
"total": "1",
"hash": "CE457673AAFC5332A11C9DA2E3CD98652F85D1983C23E3016C9704DD004E4188"
}
},
"timestamp": "2019-09-09T07:38:32.0507361Z",
"validator_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"validator_index": "0",
"signature": "caEDGKx6Nqr7Deg9u85aqcWMq+eIUyX6jTAA/y6bgJv6jkN2fWnLvKYOFRajdcsBqr2BwYpkyDLDMZcsmKmIAg=="
}
]
}
}
}
}
/block_results
说明:仅获取区块交易信息
参数height表示区块高度,不传或者传0时,默认为最新的区块高度
示例:
C:\Users\ch>curl -s "localhost:26657/block_results?height=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"height": "10",
"results": {
"deliver_tx": [
{
"log": "DeliverTx OK",
"events": [
{
"type": "app",
"attributes": [
{
"key": "Y3JlYXRvcg==",
"value": "Q29zbW9zaGkgTmV0b3dva28="
},
{
"key": "a2V5",
"value": "YXV0aG9yNw=="
}
]
}
]
}
],
"end_block": {
"validator_updates": null
},
"begin_block": {}
}
}
}
/commit
说明:获取指定高度的提交结果
参数height表示区块高度,不传或者传0时,默认为最新的区块高度
示例:
C:\Users\ch>curl -s "localhost:26657/commit?height=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"signed_header": {
"header": {
"version": {
"block": "10",
"app": "1"
},
"chain_id": "test-chain-17UaI5",
"height": "10",
"time": "2019-09-09T07:38:32.0507361Z",
"num_txs": "1",
"total_txs": "8",
"last_block_id": {
"hash": "C781443961064AB326D14105C0B4AA31F80772EE9824D8962AF92993557A4AE4",
"parts": {
"total": "1",
"hash": "CE457673AAFC5332A11C9DA2E3CD98652F85D1983C23E3016C9704DD004E4188"
}
},
"last_commit_hash": "326DB19B9B3D90464C31EF70BF8CC892944C719DF2CC586944A047DD76D0C7E0",
"data_hash": "9EE9AE5B6BE62129743563FB35B1BC7FB28E1217D551B5F3BC087F811A44F7C5",
"validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"next_validators_hash": "B5A29881AA2292F54E7AD9487F194670110FBE6D0F154CEE5E72A94048184312",
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
"app_hash": "0E00000000000000",
"last_results_hash": "6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D",
"evidence_hash": "",
"proposer_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607"
},
"commit": {
"block_id": {
"hash": "31FB364FFDC92C8EC5F63FE54E430D2996A31D3A3DBA416B3D17E13A76C5A300",
"parts": {
"total": "1",
"hash": "897CB6F0FEC7DCCFB1BD84933CBACA2064FEB8659925E7252F3AD8054BA1C655"
}
},
"precommits": [
{
"type": 2,
"height": "10",
"round": "0",
"block_id": {
"hash": "31FB364FFDC92C8EC5F63FE54E430D2996A31D3A3DBA416B3D17E13A76C5A300",
"parts": {
"total": "1",
"hash": "897CB6F0FEC7DCCFB1BD84933CBACA2064FEB8659925E7252F3AD8054BA1C655"
}
},
"timestamp": "2019-09-09T07:38:33.0507361Z",
"validator_address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"validator_index": "0",
"signature": "UODeYhbxswJcLlYnGiXoQACKEHuXYjpJxEwqVEnokAxQpl//uKGeiwJI6FAxsy8ycUeEqQ9OE5Crg9b4DX92AQ=="
}
]
}
},
"canonical": true
}
}
/validators
说明:获取在指定高度的validators
参数height表示区块高度,不传或者传0时,默认为最新的区块高度
示例:
C:\Users\ch>curl -s "localhost:26657/validators?height=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"block_height": "10",
"validators": [
{
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10",
"proposer_priority": "0"
}
]
}
}
/genesis
说明:获取创世参数
示例:
C:\Users\ch>curl -s "localhost:26657/genesis"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"genesis": {
"genesis_time": "2019-08-03T09:11:17.0099169Z",
"chain_id": "test-chain-17UaI5",
"consensus_params": {
"block": {
"max_bytes": "22020096",
"max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {
"max_age": "100000"
},
"validator": {
"pub_key_types": [
"ed25519"
]
}
},
"validators": [
{
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"power": "10",
"name": ""
}
],
"app_hash": ""
}
}
}
/dump_consensus_state
说明:获取共识状态
示例:
C:\Users\ch>curl -s "localhost:26657/dump_consensus_state"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"round_state": {
"height": "14",
"round": "0",
"step": 2,
"start_time": "2019-09-09T07:38:28.4411925Z",
"commit_time": "2019-09-09T07:38:27.4411925Z",
"validators": {
"validators": [
{
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10",
"proposer_priority": "0"
}
],
"proposer": {
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10",
"proposer_priority": "0"
}
},
"proposal": null,
"proposal_block": null,
"proposal_block_parts": null,
"locked_round": "-1",
"locked_block": null,
"locked_block_parts": null,
"valid_round": "-1",
"valid_block": null,
"valid_block_parts": null,
"votes": [
{
"round": "0",
"prevotes": [
"nil-Vote"
],
"prevotes_bit_array": "BA{1:_} 0/10 = 0.00",
"precommits": [
"nil-Vote"
],
"precommits_bit_array": "BA{1:_} 0/10 = 0.00"
},
{
"round": "1",
"prevotes": [
"nil-Vote"
],
"prevotes_bit_array": "BA{1:_} 0/10 = 0.00",
"precommits": [
"nil-Vote"
],
"precommits_bit_array": "BA{1:_} 0/10 = 0.00"
}
],
"commit_round": "-1",
"last_commit": {
"votes": [
"Vote{0:214F0751415B 13/00/2(Precommit) 2211B8262B62 9BF9FF8FC46C @ 2019-09-09T07:38:36.0507361Z}"
],
"votes_bit_array": "BA{1:x} 10/10 = 1.00",
"peer_maj_23s": {}
},
"last_validators": {
"validators": [
{
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10",
"proposer_priority": "0"
}
],
"proposer": {
"address": "214F0751415B6EEF19E4D81D9422B3C8EC5F3607",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "GDTnQdrcRX0wwZ13cudz3yHNuk0UHp9MbXwVnyDzKRY="
},
"voting_power": "10",
"proposer_priority": "0"
}
},
"triggered_timeout_precommit": false
},
"peers": []
}
}
/consensus_state
说明:获取共识状态
示例:
C:\Users\ch>curl -s "localhost:26657/consensus_state"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"round_state": {
"height/round/step": "14/0/2",
"start_time": "2019-09-09T07:38:28.4411925Z",
"proposal_block_hash": "",
"locked_block_hash": "",
"valid_block_hash": "",
"height_vote_set": [
{
"round": "0",
"prevotes": [
"nil-Vote"
],
"prevotes_bit_array": "BA{1:_} 0/10 = 0.00",
"precommits": [
"nil-Vote"
],
"precommits_bit_array": "BA{1:_} 0/10 = 0.00"
},
{
"round": "1",
"prevotes": [
"nil-Vote"
],
"prevotes_bit_array": "BA{1:_} 0/10 = 0.00",
"precommits": [
"nil-Vote"
],
"precommits_bit_array": "BA{1:_} 0/10 = 0.00"
}
]
}
}
}
/consensus_params
说明:获取共识参数
参数height表示区块高度,不传或者传0时,默认为最新的区块高度
示例:
C:\Users\ch>curl -s "localhost:26657/consensus_params?height=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"block_height": "14",
"consensus_params": {
"block": {
"max_bytes": "22020096",
"max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {
"max_age": "100000"
},
"validator": {
"pub_key_types": [
"ed25519"
]
}
}
}
}
/unconfirmed_txs
说明:获取没有被确认的交易列表
参数limit限制返回最大数量
示例:
C:\Users\ch>curl -s "localhost:26657/unconfirmed_txs"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"n_txs": "0",
"total": "0",
"total_bytes": "0",
"txs": []
}
}
/num_unconfirmed_txs
说明:获取没有被确认的交易条数
示例:
C:\Users\ch>curl -s "localhost:26657/num_unconfirmed_txs"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"n_txs": "0",
"total": "0",
"total_bytes": "0",
"txs": null
}
}
/tx_search
说明:获取未确认的交易列表
参数:
query,查询条件,必填
prove,是否包含块中交易的证明,非必填,默认false
page,第几页,非必填,默认为1
per_page,每页多少数据,非必填,默认30
这个接口和/unconfirmed_txs相比,是可以分页的
示例:
C:\Users\ch>curl -s "localhost:26657/tx_search?query=\"tx.height=10\"&prove=true&page=1&per_page=10"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"txs": [],
"total_count": "0"
}
}
/tx
说明:根据hash查询某笔交易
参数:
hash,交易hash,必填
prove,是否包含块中交易的证明,非必填,默认false
示例:
C:\Users\ch>curl -s "localhost:26657/tx?hash=0xFC2343E093599A71C62F89C533ACB30291477F748056C7F0E9E7AB5304617343&prove=true"
{
"jsonrpc": "2.0",
"id": "",
"result": {
"hash": "FC2343E093599A71C62F89C533ACB30291477F748056C7F0E9E7AB5304617343",
"height": "12",
"index": 0,
"tx_result": {
"log": "DeliverTx OK",
"events": [
{
"type": "app",
"attributes": [
{
"key": "Y3JlYXRvcg==",
"value": "Q29zbW9zaGkgTmV0b3dva28="
},
{
"key": "a2V5",
"value": "YXV0aG9yOQ=="
}
]
}
]
},
"tx": "YXV0aG9yOT1jYW9odWFuOQ==",
"proof": {
"RootHash": "2C1B2D82E610AB0518C0EC8FC62B08CAF8FF2D470F5A9219967D641107627A82",
"Data": "YXV0aG9yOT1jYW9odWFuOQ==",
"Proof": {
"total": "1",
"index": "0",
"leaf_hash": "LBstguYQqwUYwOyPxisIyvj/LUcPWpIZln1kEQdieoI=",
"aunts": []
}
}
}
}
/broadcast_evidence
说明:
示例:
转载请注明来源