getBlockByHeight

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}")
}
}

Return

A Result which is either Result.Ok containing the Block information, or Result.Err containing an AptosSdkError.

Parameters

ledgerHeight

Ledger height to look up block information for.

withTransactions

Whether to include the full transaction data in the response.