get Block By Version
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}")
}
}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
Ledger version to look up block information for.
with Transactions
Whether to include the full transaction data in the response.