Transaction
public class Transaction : @unchecked Sendable
Represents a Transaction in Stellar network. See Stellar developer docs
-
The minimum fee per operation in stroops. Currently set to 100 stroops.
Declaration
Swift
public static let minBaseFee: UInt32 -
The transaction fee in stroops (1 stroop = 0.0000001 XLM).
Declaration
Swift
public var fee: UInt32 { get } -
The account that originates the transaction.
Declaration
Swift
public let sourceAccount: TransactionAccount -
The list of operations contained in this transaction.
Declaration
Swift
public var operations: [Operation] { get } -
Optional extra information attached to the transaction.
Declaration
Swift
public var memo: Memo { get } -
Transaction validity constraints as defined in CAP-21.
Declaration
Swift
public var preconditions: TransactionPreconditions? { get } -
The XDR representation of this transaction.
Declaration
Swift
public var transactionXDR: TransactionXDR { get } -
The base64-encoded XDR string of this transaction.
Declaration
Swift
public var xdrEncoded: String? { get } -
Creates a new Transaction object.
Declaration
Swift
public init(sourceAccount: TransactionAccount, operations: [Operation], memo: Memo?, preconditions: TransactionPreconditions? = nil, maxOperationFee: UInt32 = Transaction.minBaseFee, sorobanTransactionData: SorobanTransactionDataXDR? = nil) throwsParameters
sourceAccountAccount that originates the transaction.
operationsTransactions contain an arbitrary list of operations inside them. Typically there is just one operation, but it’s possible to have multiple. Operations are executed in order as one ACID transaction, meaning that either all operations are applied or none are.
memoOptional. The memo contains optional extra information. It is the responsibility of the client to interpret this value.
preconditionsOptional. Transaction preconditions as defined in CAP-21
maxOperationFeeOptional. The maximum fee in stoops you are willing to pay per operation. If not set, it will default to the network base fee which is currently set to 100 stroops (0.00001 lumens). Transaction fee is equal to operation fee times number of operations in this transaction.
sorobanTransactionDataOptional. Soroban Transaction Data
-
Deprecated initializer that uses TimeBounds instead of TransactionPreconditions.
Declaration
Swift
@available(*, deprecated, message: "use init with preconditions instead") public convenience init(sourceAccount: TransactionAccount, operations: [Operation], memo: Memo?, timeBounds: TimeBounds?, maxOperationFee: UInt32 = Transaction.minBaseFee) throws -
Creates a new Transaction object from an XDR string.
Declaration
Swift
public convenience init(xdr: String) throwsParameters
xdrThe XDR string to be parsed into a Transaction object.
-
Creates a new Transaction object from an Transaction Envelope XDR string.
Declaration
Swift
public convenience init(envelopeXdr: String) throwsParameters
envelopeXdrThe XDR string to be parsed into a Transaction object.
-
Each transaction needs to be signed before sending it to the stellar network.
Parameters
keyPairkey pair to be used as a signer. Must containing the private key.
networkNetwork to specify which Stellar network you want to use.
-
Adds a pre-computed signature to the transaction without requiring the private key.
Declaration
Swift
public func addSignature(signature: DecoratedSignatureXDR) -
Returns the base64-encoded transaction envelope XDR for submission to the network.
Declaration
Swift
public func encodedEnvelope() throws -> String -
Computes and returns the transaction hash as a hex-encoded string for the specified network.
Declaration
Swift
public func getTransactionHash(network: Network) throws -> String -
Computes and returns the transaction hash as Data for the specified network.
Declaration
Swift
public func getTransactionHashData(network: Network) throws -> Data -
Sets the Soroban transaction data extension for smart contract invocations.
Declaration
Swift
public func setSorobanTransactionData(data: SorobanTransactionDataXDR) -
Adds additional resource fee in stroops for Soroban smart contract operations.
Declaration
Swift
public func addResourceFee(resourceFee: UInt32) -
Sets Soroban authorization entries for all InvokeHostFunction operations in this transaction.
Declaration
Swift
public func setSorobanAuth(auth: [SorobanAuthorizationEntryXDR]?) -
Updates the transaction memo. If nil, sets memo to none.
Declaration
Swift
public func setMemo(memo: Memo? = nil) -
Updates the transaction preconditions. If nil, removes all preconditions.
Declaration
Swift
public func setPreconditions(preconditions: TransactionPreconditions? = nil) -
Sets the total transaction fee in stroops. Use this to override the calculated fee.
Declaration
Swift
public func setFee(fee: UInt32) -
Appends an operation to the transaction’s operation list.
Declaration
Swift
public func addOperation(operation: Operation) throws
View on GitHub
Install in Dash