get Block By Version
abstract suspend fun getBlockByVersion(ledgerVersion: Long, withTransactions: Boolean? = null): Result<Block, AptosSdkError>
Retrieves block information by a specific ledger version.
Usage
val aptos = Aptos(AptosConfig(AptosSettings(network = Network.LOCAL)))
val resolution = aptos.getBlockByVersion(2L)
when (resolution) {
is Result.Ok -> {
val block = resolution.value
println("Block height is: ${block.blockHeight}")
}
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 Version
The ledger version to look up block information for.
with Transactions
If set to true, includes all transactions in the block.