get Block By Height
open suspend override fun getBlockByHeight(ledgerHeight: Long, withTransactions: Boolean?): Result<Block, AptosSdkError>
Retrieves a block by its height.
Usage
val resolution = aptos.getBlockByHeight(100)
when (resolution) {
is Result.Ok -> {
val block = resolution.value
println("Block version is: ${block.ledgerVersion}")
}
is Result.Err -> {
println("Error retrieving block: ${resolution.error.message}")
}
}Content copied to clipboard
Return
A Result which is either Result.Ok containing the Block information, or Result.Err containing an AptosSdkError.
Parameters
ledger Height
Ledger height to look up block information for.
with Transactions
Whether to include the full transaction data in the response.