Transaction Builder
Builds a new Transaction following the builder pattern.
TransactionBuilder provides a fluent API for constructing Stellar transactions with all necessary parameters and validations.
Usage
val sourceAccount = Account("GABC...", 1234567890)
val transaction = TransactionBuilder(sourceAccount, Network.TESTNET)
.setBaseFee(100)
.addOperation(
PaymentOperation(
destination = "GDEF...",
asset = AssetTypeNative,
amount = "10.0"
)
)
.addMemo(MemoText("Payment"))
.setTimeout(300) // 5 minutes from now
.build()
transaction.sign(keypair)Fee Calculation
The transaction fee is calculated as: baseFee * operations.size
You must set the base fee explicitly using setBaseFee before building.
Sequence Number Management
The builder automatically increments the source account's sequence number when build is called. This ensures the transaction has the correct sequence number (account.sequence + 1).
See also
Functions
Adds a memo to this transaction.
Adds an operation to this transaction.
Adds multiple operations to this transaction.
Adds preconditions to this transaction.
Adds time bounds to this transaction.
Builds the transaction and increments the source account's sequence number.
Returns the number of operations currently added to this transaction.
Sets the base fee per operation for this transaction.
Sets Soroban transaction data for smart contract operations.
Sets the transaction timeout in seconds from now.
Sets the transaction timeout using Kotlin Duration from now.