Skip to main content

Block query APIs

Nodes provide interfaces for querying block related information.

GetBlockByHeight

  • Get block height

Request the "GetBlockByHeight" interface from the request node with begin height and end height

For example: http://IP:port/GetBlockByHeight


curl http://localhost:20620/GetBlockByHeight -X POST -H "Content-Type: application/json" -d '
{
"id":"1",
"jsonrpc":"2.0",
"params":{"beginHeight":"2484", "endHeight":"2584"}
}
'

Sample Request:

{
"id":"1",
"jsonrpc":"2.0",
"params":{"beginHeight":"2484", "endHeight":"2584"}
}

Sample Response:

{
"id": "1",
"jsonrpc": "2.0",
"method": "GetBlockByHeight",
"result": {
"blocks": [
{
"block": {
"blocksign": [
{
"pub": "MCowBQYDK2VwAyEAYc23TU7Tw6L9QcUXNM6FuS5kEzTTQEfX15dR9+n251Y=",
"sign": "nYmcHtPifKAydKyaP8UOhfyPsxLfUg4cscFx4aW8BdGp0MzBnJGajgrYr35QY2QGMh8KSsldcjwqaDP1t4aZAA==",
"signaddr": "0xadc2A709EC1413eCcEB4d115E50BD9ebBA35E3Ce"
}
],
"bytes": 2398,
"data": {
"dependentCTx": ""
},
"hash": "0x85b85a2b88a9c993f44c21f45e43ff537eacfe08257d913ac9adcda223d14d4c",
"height": 2484,
"merkleroot": "0x446bd7acc5487883475b2c581f0c343bd9630adc35c88b584a52d5a2faec7ce8",
"prevhash": "0xd0e8f63a7479df2cec92c701b4650eff8fbb31af6dba955f426b6966ea4541da",
"time": 1717401536067676
},
"tx": [
{
"Consensus": 7,
"Type": "Tx",
"data": {
"TxInfo": {
"BonusAddr": "0xadc2A709EC1413eCcEB4d115E50BD9ebBA35E3Ce",
"InvestAmount": 800000000000,
"InvestType": "Normal"
}
},
"identity": "0xadc2A709EC1413eCcEB4d115E50BD9ebBA35E3Ce",
"info": "MQ==",
"time": 1717401535678450,
"txHash": "0x446bd7acc5487883475b2c581f0c343bd9630adc35c88b584a52d5a2faec7ce8",
"txType": 4,
"utxo": {
"multisign": [
{
"pub": "agc3qfYFfCGRHMJLSm/M37b32hITmFbt0VokGeECaEKazDrrUVDvwmRHY7QH/6lNMuuCVyfebhSjUr3AXW1ECg==",
"sign": "agc3qfYFfCGRHMJLSm/M37b32hITmFbt0VokGeECaEKazDrrUVDvwmRHY7QH/6lNMuuCVyfebhSjUr3AXW1ECg=="
}
],
"owner": [
"0x638c172F63db3caf32c410D0188143E0Eff74bC8"
],
"vin": {
"prevout": {
"hash": [
"0xd738eaacbba575fff85f12d356bba157ff6dc1fcdf6c470ddf4d15cca26db7c5"
]
},
"vinsign": [
{
"pub": "MCowBQYDK2VwAyEA878WPUVdMcjoPM+ZI1qC59e8nLgNXi/MAGIRFyU0kPM=",
"sign": "4H63JOxLz7T4ZxLaVAd3VMS3JUCAfv1blpaNVOM8vFyKrkk5NULHay5unpWlXQjIDEjOJCWo9jttJsoBXJbhBw=="
}
]
},
"vout": [
{
"addr": "VirtualInvest",
"value": 800000000000
},
{
"addr": "0x638c172F63db3caf32c410D0188143E0Eff74bC8",
"value": 2199999967700
},
{
"addr": "VirtualBurnGas",
"value": 32300
}
]
},
"verifySign": [
{
"pub": "MCowBQYDK2VwAyEAYc23TU7Tw6L9QcUXNM6FuS5kEzTTQEfX15dR9+n251Y=",
"sign": "5+excKFT9ZgiLS12P2zrRzy565esiAtckqcFpsjWHY/6gWAJv6++5m9mn+P5eRhK8kU2iBGS4cIY7+lxadWiAA==",
"signaddr": "0xadc2A709EC1413eCcEB4d115E50BD9ebBA35E3Ce"
}
]
}
]
}
],
"code": 0,
"message": "success"
}
}

GetBlockNumber

  • Get top block number info

For example: http://IP:port/GetBlockNumber

curl http://localhost:20620/GetBlockNumber -X POST -H "Content-Type: application/json" -d '
{
"id":"1",
"jsonrpc":"2.0",
}
'

Return as follows:

{
"id": "1",
"jsonrpc": "2.0",
"method": "GetBlockNumber",
"result": {
"code": 0,
"message": "success",
"top": "590"
}
}

GetBlockByHash

  • Query block information through block hash

Just request the "GetBlockByHash" interface from the request block info with block hash parameters

For example: http://IP:port/GetBlockByHash


curl http://localhost:20620/GetBlockByHash -X POST -H "Content-Type: application/json" -d '
{
"id":"1",
"jsonrpc":"2.0",
"params":{"blockHash":"139009febd771d3f0d49d0ec179a8706e362af48a989dcfededb4aa2a18aaa08"}
}
'

Sample Request:

{
"id":"1",
"jsonrpc":"2.0",
"params":{"blockHash":"139009febd771d3f0d49d0ec179a8706e362af48a989dcfededb4aa2a18aaa08"}
}

Sample Response:

{
"id": "1",
"jsonrpc": "2.0",
"method": "GetBlockByHash",
"result": {
"blockInfo": {
"block": {
"blocksign": [
{
"pub": "MCowBQYDK2VwAyEAvU/OXGoLVyRBFQe8V9FuD9xDVsTMhIkF6MQjCQjeaX4=",
"sign": "wL1MIpdaX1n6jwmt+Vt7NF+emCsCVkT1aOAw0jv2mhLMe3g4t1c/dNQ0zUBZWsbhnDDwIi7g30fG9S6ryanyAw==",
"signaddr": "0x116058AcF188BB96F9Da1317Bd11fD737E4f8Cd2"
}
],
"bytes": 2399,
"data": {
"dependentCTx": ""
},
"hash": "0x139009febd771d3f0d49d0ec179a8706e362af48a989dcfededb4aa2a18aaa08",
"height": 541,
"merkleroot": "0x434026a97ff15f3519a95f3600c527d8b68cc72f279a4e36705b526900cbfbf0",
"prevhash": "0x96c1691d58d2cbec05eaf8792b2cd58fbbea0aad19ad3daf27b665fb5886f33c",
"time": 1716796707667741
},
"tx": [
{
"Consensus": 7,
"Type": "Tx",
"data": {
"TxInfo": {
"BonusAddr": "0x855052fa258B463AEAd1E5abD55F2ffbCBb3F022",
"InvestAmount": 1000000000000,
"InvestType": "Normal"
}
},
"identity": "0x116058AcF188BB96F9Da1317Bd11fD737E4f8Cd2",
"info": "MQ==",
"time": 1716796705692762,
"txHash": "0x434026a97ff15f3519a95f3600c527d8b68cc72f279a4e36705b526900cbfbf0",
"txType": 4,
"utxo": {
"multisign": [
{
"pub": "scIqQ/SPPhUc2egQgpEL21qk/NcnoH//xOv5h8M1hSXUGAM3CuitY1FEPI0QtRvXV5hmcajQlWDEDJ3bQDjVCg==",
"sign": "scIqQ/SPPhUc2egQgpEL21qk/NcnoH//xOv5h8M1hSXUGAM3CuitY1FEPI0QtRvXV5hmcajQlWDEDJ3bQDjVCg=="
}
],
"owner": [
"0x855052fa258B463AEAd1E5abD55F2ffbCBb3F022"
],
"vin": {
"prevout": {
"hash": [
"0x7637b67f47793d4bb9b017ead8d987971516e5b49a1073c8c6691f1e12c7ad6a"
]
},
"vinsign": [
{
"pub": "MCowBQYDK2VwAyEAwigpWZg9E0DRbbbNuE4PDHT7MJ9XIH2hh5yADHNa6jw=",
"sign": "wsdl+IJJ8aaC3q/em5cmUidQllESaePErugQT2xeUdRtohw7PQmi0X899BgZZE1sh8rhYnCC68kf19Y9W+ykAg=="
}
]
},
"vout": [
{
"addr": "VirtualInvest",
"value": 1000000000000
},
{
"addr": "0x855052fa258B463AEAd1E5abD55F2ffbCBb3F022",
"value": 1899998701374
},
{
"addr": "VirtualBurnGas",
"value": 32400
}
]
},
"verifySign": [
{
"pub": "MCowBQYDK2VwAyEAvU/OXGoLVyRBFQe8V9FuD9xDVsTMhIkF6MQjCQjeaX4=",
"sign": "yLr5Zft97qilx6KUPopmWwgVUG5WBG+rxU6gH+DtMKXNQkO7Fm+3/y3gAohj9UPhf7ECI+fTKczUz35tjC+/Bg==",
"signaddr": "0x116058AcF188BB96F9Da1317Bd11fD737E4f8Cd2"
},
{
"pub": "MCowBQYDK2VwAyEAh6RFUhVdsoE3MehHfFNlj4tWgyzLo+8F6SIPbW7zIYw=",
"sign": "",
"signaddr": "0x28bA6E30cB0d9372a18c80552eE11DFe47883FAd"
}
]
}
]
},
"code": 0,
"message": "success"
}
}

GetBlockTransactionCountByHash

  • Query the number of transactions through block hash

Just request the "GetBlockTransactionCountByHash" interface from the request transaction quantity with block hash parameters

For example: http://IP:port/GetBlockTransactionCountByHash


curl http://localhost:20620/GetBlockTransactionCountByHash -X POST -H "Content-Type: application/json" -d '
{
"id":"1",
"jsonrpc":"2.0",
"params":{"blockHash":"0x12e52383dc0fedc40bdab13fc1afd851d7123facf030f90163c03f87411650f1"}
}
'

Sample Request:

{
"id":"1",
"jsonrpc":"2.0",
"params":{"blockHash":"0x12e52383dc0fedc40bdab13fc1afd851d7123facf030f90163c03f87411650f1"}
}

Sample Response:

{
"id": "1",
"jsonrpc": "2.0",
"method": "GetBlockTransactionCountByHash",
"result": {
"code": 0,
"message": "success",
"txCount": "1"
}
}