Query for block headers
queryBlockHeader
This API is used to query for block headers by block hash.
- Function prototype
public QueryBlockHeaderResponse queryBlockHeader(Hash hash)
The following table describes the basic parameter for a block header query.
Parameter | Required | Type | Description |
---|---|---|---|
hash | true | Hash | The block hash. |
- Example
QueryBlockHeaderResponse replyBlockHeader = sdk.getQueryService().queryBlockHeader(hash);
queryBlockHeaderByNumber
This API is used to query for block headers by block number.
- Function prototype
public QueryBlockHeaderResponse queryBlockHeaderByNumber(BigInteger blockNumber)
The following table describes the basic parameter for a block header query.
Parameter | Required | Type | Description |
---|---|---|---|
blockNumber | true | BigInteger | The block number. |
- Example
QueryBlockHeaderResponse replyBlockHeader = sdk.getQueryService().queryBlockHeaderByNumber(blockNumber);
queryLastBlockHeader
This API is used to query for the last block header.
- Function prototype
public QueryLastBlockHeaderResponse queryLastBlockHeader()
- Example
QueryLastBlockHeaderResponse result = sdk.getQueryService().queryLastBlockHeader();
Query for blocks
queryBlock
This API is used to query for blocks by block hash.
- Function prototype
public QueryBlockResponse queryBlock(Hash hash)
The following table describes the basic parameter for a block query.
Parameter | Required | Type | Description |
---|---|---|---|
hash | true | Hash | The block hash. |
- Example
QueryBlockResponse replyBlock = sdk.getQueryService().queryBlock(hash);
queryBlockByNumber
This API is used to query for blocks by block number.
- Function prototype
public QueryBlockResponse queryBlockByNumber(BigInteger blockNumber)
The following table describes the basic parameter for a block query.
Parameter | Required | Type | Description |
---|---|---|---|
blockNumber | true | BigInteger | The block number. |
- Example
QueryBlockResponse replyBlock = sdk.getQueryService().queryBlockByNumber(blockNumber);
queryLastBlock
This API is used to query for the last block.
- Function prototype
public QueryLastBlockResponse queryLastBlock()
- Example
QueryLastBlockResponse result = sdk.getQueryService().queryLastBlock();
Query for transactions
queryTransaction is used to query for transactions by transaction hash.
- Function prototype
public QueryTransactionResponse queryTransaction(Hash hash)
public QueryTransactionResponse queryTransaction(Hash hash, BaseFixedSizeByteArray.Fixed20ByteArray groupId)
The following table describes the basic parameters for a transaction query by transaction hash.
Parameter | Required | Type | Description |
---|---|---|---|
hash | true | String | The transaction hash. |
groupId | false | Fixed20ByteArray | The group where the transactions are queried. |
- Example
QueryTransactionResponse result = sdk.getQueryService().queryTransaction(hash);
Query for receipts
queryTransactionReceipt is used to query for receipts by transaction hash.
- Function prototype
public QueryTransactionReceiptResponse queryTransactionReceipt(Hash hash)
public QueryTransactionReceiptResponse queryTransactionReceipt(Hash hash, BaseFixedSizeByteArray.Fixed20ByteArray groupId)
The following table describes the basic parameters for a receipt query by transaction hash.
Parameter | Required | Type | Description |
---|---|---|---|
hash | true | String | The transaction hash. |
groupId | false | Fixed20ByteArray | The group where the receipts are queried. |
- Example
QueryTransactionReceiptResponse result = sdk.getQueryService().queryTransactionReceipt(hash);
Query for accounts
queryAccount is used to query for accounts by account ID.
- Function prototype
public QueryAccountResponse queryAccount(Identity acctId)
The following table describes the basic parameter for an account query by account ID.
Parameter | Required | Type | Description |
---|---|---|---|
acctId | true | Identity | The account ID. |
- Example
QueryAccountResponse result = sdk.getQueryService().queryAccount(acctId);
Query for contracts
queryContract is used to query for contracts by contract account.
- Function prototype
public QueryContractResponse queryContract(Identity acctId)
The following table describes the basic parameter for a contract query by contract account.
Parameter | Required | Type | Description |
---|---|---|---|
acctId | true | Identity | The account ID. |
- Example
QueryContractResponse result = sdk.getQueryService().queryContract(acctId);
Query a block for transaction receipts
queryBlockTxReceipts is used to query a block for transaction receipts by block height.
- Function prototype
public QueryBlockTxReceiptsResponse queryBlockTxReceipts(BigInteger blockNumber);
The following table describes the basic parameter for querying a block for transaction receipts by block height.
Parameter | Required | Type | Description |
---|---|---|---|
blockNumber | true | BigInteger | The block height. |
- Example
QueryContractResponse result = sdk.getQueryService().queryContract(BigIntger.valueOf(1L);