GetTransactionResponse

public struct GetTransactionResponse : Decodable, Sendable

Response when polling for transaction completion status.

After submitting a transaction with sendTransaction, use this response to check if the transaction has been included in a ledger and whether it succeeded or failed.

Transaction status values:

  • SUCCESS: Transaction was included in a ledger and executed successfully
  • FAILED: Transaction was included but execution failed
  • NOT_FOUND: Transaction not found (may still be pending or has expired)

For successful transactions, this response contains:

  • The return value from contract invocations
  • Events emitted during execution
  • The ledger number and timestamp when included
  • Complete transaction metadata

For failed transactions, check the error field for details about why it failed.

Example:

let response = await server.getTransaction(transactionHash: txHash)
switch response {
case .success(let txInfo):
    switch txInfo.status {
    case GetTransactionResponse.STATUS_SUCCESS:
        print("Transaction succeeded in ledger \(txInfo.ledger ?? 0)")
        if let result = txInfo.resultValue {
            print("Contract returned: \(result)")
        }
        // Process events
        if let events = txInfo.events {
            for event in events.events {
                print("Event: \(event)")
            }
        }
    case GetTransactionResponse.STATUS_FAILED:
        if let error = txInfo.error {
            print("Transaction failed: \(error.message)")
        }
    case GetTransactionResponse.STATUS_NOT_FOUND:
        print("Transaction not yet included")
    default:
        print("Unknown status: \(txInfo.status)")
    }
case .failure(let error):
    print("RPC error: \(error)")
}

See also:

  • Transaction was successfully included in a ledger and executed.

    Declaration

    Swift

    public static let STATUS_SUCCESS: String
  • Transaction not found in Soroban RPC (may be pending or expired).

    Declaration

    Swift

    public static let STATUS_NOT_FOUND: String
  • Transaction failed during execution.

    Declaration

    Swift

    public static let STATUS_FAILED: String
  • The current status of the transaction by hash, one of: SUCCESS, NOT_FOUND, FAILED

    Declaration

    Swift

    public let status: String
  • The sequence number of the latest ledger known to Soroban RPC at the time it handled the request.

    Declaration

    Swift

    public let latestLedger: Int
  • The unix timestamp of the close time of the oldest ledger ingested by Soroban RPC at the time it handled the request.

    Declaration

    Swift

    public let latestLedgerCloseTime: String
  • The sequence number of the oldest ledger ingested by Soroban RPC at the time it handled the request.

    Declaration

    Swift

    public let oldestLedger: Int
  • The unix timestamp of the close time of the oldest ledger ingested by Soroban RPC at the time it handled the request.

    Declaration

    Swift

    public let oldestLedgerCloseTime: String?
  • (optional) The sequence number of the ledger which included the transaction. This field is only present if status is SUCCESS or FAILED

    Declaration

    Swift

    public let ledger: Int?
  • (optional) The unix timestamp of when the transaction was included in the ledger. This field is only present if status is SUCCESS or FAILED.

    Declaration

    Swift

    public let createdAt: String?
  • (optional) The index of the transaction among all transactions included in the ledger. This field is only present if status is SUCCESS or FAILED.

    Declaration

    Swift

    public let applicationOrder: Int?
  • (optional) Indicates whether the transaction was fee bumped. This field is only present if status is SUCCESS or FAILED.

    Declaration

    Swift

    public let feeBump: Bool?
  • (optional) A base64 encoded string of the raw TransactionEnvelope XDR struct for this transaction.

    Declaration

    Swift

    public let envelopeXdr: String?
  • (optional) A base64 encoded string of the raw TransactionResult XDR struct for this transaction. This field is only present if status is SUCCESS or FAILED.

    Declaration

    Swift

    public let resultXdr: String?
  • (optional) A base64 encoded string of the raw TransactionMeta XDR struct for this transaction.

    Declaration

    Swift

    public let resultMetaXdr: String?
  • hex-encoded transaction hash string. Only available for protocol version >= 22

    Declaration

    Swift

    public let txHash: String?
  • (optional) Will be present on failed transactions.

    Declaration

    Swift

    public let error: TransactionStatusError?
  • events for the transaction. Only available for protocol version >= 23

    Declaration

    Swift

    public let events: TransactionEvents?
  • Declaration

    Swift

    public init(from decoder: Decoder) throws
  • Extracts the value from the first transaction status result

    Declaration

    Swift

    public var resultValue: SCValXDR? { get }
  • Converts the envelopeXdr value to a TransactionEnvelopeXDR if present and valid

    Declaration

    Swift

    public var transactionEnvelope: TransactionEnvelopeXDR? { get }
  • Converts the resultXdr value to a TransactionResultXDR if present and valid

    Declaration

    Swift

    public var transactionResult: TransactionResultXDR? { get }
  • Converts the resultMetaXdr value to a TransactionMetaXDR if present and valid

    Declaration

    Swift

    public var transactionMeta: TransactionMetaXDR? { get }
  • Extracts the wasm id from the response if the transaction installed a contract

    Declaration

    Swift

    public var wasmId: String? { get }
  • Extracts the wasm id from the response if the transaction created a contract

    Declaration

    Swift

    public var createdContractId: String? { get }