getBlockByVersion

open suspend override fun getBlockByVersion(ledgerVersion: Long, withTransactions: Boolean?): Result<Block, AptosSdkError>

Retrieves a block by its transaction version number.

Usage

val resolution = aptos.getBlockByVersion(123456)
when (resolution) {
is Result.Ok -> {
val block = resolution.value
println("Block found at version: ${block.blockHeight}")
}
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

ledgerVersion

Ledger version to look up block information for.

withTransactions

Whether to include the full transaction data in the response.