Querying the Blockchain
hmy
provides several subcommands under the blockchain
subcommand which let you query the blockchain.
List of available commands
By using ./hmy blockchain help
command we can see that the following options are available:
Here are some examples of the above commands that you will use frequently:
transaction-by-hash
Checking the hash of your transaction to see the transaction data and if the transaction has been completed
Using the Binary:
./hmy blockchain transaction-by-hash <transaction-hash> --node="<endpoint-address>"
Using the Shell Wrapper:
./hmy.sh -- blockchain transaction-by-hash <transaction-hash> --node="<endpoint-address>"
Example:
./hmy blockchain transaction-by-hash 0x75d91100734edcd1497200cb438f0864d2ed4a44a88bf8c87855cb2b3cc54001 --node="https://api.s0.t.hmny.io"
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"blockHash": "0xf9c7e165d5636c7dd8a06bf2c53c364d7597028d7e10a3c5256462adf97b1f73",
"blockNumber": "0xa35",
"from": "one1mrrq665uarrmfur6hptevx9furph4293a37zme",
"gas": "0x5208",
"gasPrice": "0x3b9aca00",
"hash": "0x75d91100734edcd1497200cb438f0864d2ed4a44a88bf8c87855cb2b3cc54001",
"input": "0x",
"nonce": "0xe",
"r": "0x4a17d89f7b1818fe72d480a64fecfede1d73bd7242fcaabf907204a7022be806",
"s": "0x557be1b9c378ecbae972e71ec6fc5d484abfe8cb7961ccd87724865c3a7020bc",
"shardID": 0,
"timestamp": "0x5e1cfcc1",
"to": "one1mrrq665uarrmfur6hptevx9furph4293a37zme",
"toShardID": 1,
"transactionIndex": "0x0",
"v": "0x2a",
"value": "0xde0b6b3a7640000"
}
}
transaction-receipt
Get information about a finalized transaction:
Using the Binary:
./hmy blockchain transaction-receipt <transaction-hash> --node="<endpoint-address>"
Using the Shell Wrapper:
./hmy.sh -- blockchain transaction-receipt <transaction-hash> --node="<endpoint-address>"
Example:
./hmy blockchain transaction-receipt 0x599793f313ee17566f8d09728b9d043b8e26135ddce86beeee13f98767d452f7 --node="https://api.s0.t.hmny.io"
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"blockHash": "0x52171a8f3af94f639f1e6044679c4189c3cd088ffe7f1c216ce3089212373af9",
"blockNumber": "0x6177",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
"from": "0x261fa45c6a09cd3faa277d829e91d9473973357c",
"gasUsed": "0x5208",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"shardID": 0,
"status": "0x1",
"to": "0x06916163a17f07ce70e3d43ed37395f05b5738ae",
"transactionHash": "0x599793f313ee17566f8d09728b9d043b8e26135ddce86beeee13f98767d452f7",
"transactionIndex": "0x0"
}
}
latest-header command
Checking the network status, last block, epoch, leaders, based on the shard number:
Using the Binary:
./hmy blockchain latest-header --node="<endpoint-address>"
Using the Shell Wrapper:
./hmy.sh -- blockchain latest-header --node="<endpoint-address>"
Example:
block-by-number
Using the Binary:
./hmy blockchain block-by-number <block-number> --node="<endpoint-address>"
Using the Shell Wrapper:
./hmy.sh -- blockchain block-by-number <block-number> --node="<endpoint-address>"
Example:
./hmy blockchain block-by-number 0x29A1 --node="https://api.s0.t.hmny.io"
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"difficulty": 0,
"extraData": "0x",
"gasLimit": "0x4c4b400",
"gasUsed": "0x0",
"hash": "0x5cb6e0752530cef5e25c52539feca22b8ad197cca60c04cf06f4ee05d6537096",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x3f6e680ec5456f540a833e77df4c8ed20a20f274",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": 0,
"number": "0x29a1",
"parentHash": "0x30d28fb69701f8348e0cd6a7abbacceb4286009fc43827dc243e79508da057d7",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"size": "0x50c",
"stakingTransactions": [],
"stateRoot": "0x096fac171e818e54e611d3543fd43b1929a4468d17dcb8766d18eaf1e426749c",
"timestamp": "0x5e755a56",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
Last updated
Was this helpful?