getTransactionByHash

abstract suspend fun getTransactionByHash(transactionHash: String): Result<TransactionResponse, AptosSdkError>

Retrieves a transaction by its hash.

Note: This function can return both pending (mempool) and committed transactions.

Usage

val hash = "0x..."
val resolution = aptos.getTransactionByHash(hash)
when (resolution) {
is Result.Ok -> {
val transaction = resolution.value
println("Transaction success status: ${transaction.success}")
}
is Result.Err -> {
println("Error fetching transaction: ${resolution.error.message}")
}
}

Return

A Result containing the TransactionResponse or an AptosSdkError.

Parameters

transactionHash

The hex-encoded hash of the transaction.