Transaction
Represents a transaction in the Stellar network.
A transaction is a grouping of operations that are executed together atomically. All operations must succeed for the transaction to succeed. If any operation fails, all effects are rolled back.
Transaction Structure
A transaction consists of:
Source Account: The account that originates the transaction and pays the fee
Fee: Total fee in stroops (baseFee * operations.size)
Sequence Number: Must be exactly sourceAccount.sequence + 1
Operations: List of 1-100 operations to execute
Memo: Optional memo (up to 28 bytes for text memos)
Preconditions: Optional time bounds, ledger bounds, etc.
Signatures: List of signatures authorizing the transaction
Building Transactions
Use TransactionBuilder to construct transactions:
val sourceAccount = Account("GABC...", 1234567890)
val transaction = TransactionBuilder(sourceAccount, Network.TESTNET)
.addOperation(
PaymentOperation(
destination = "GDEF...",
asset = AssetTypeNative,
amount = "10.0"
)
)
.addMemo(MemoText("Payment for services"))
.setTimeout(300) // 5 minutes
.setBaseFee(100)
.build()
// Sign with source account keypair
transaction.sign(sourceKeypair)
// Submit to Horizon
val response = horizonServer.submitTransaction(transaction)Fee Calculation
The transaction fee is calculated as: baseFee * operations.size
The minimum base fee is 100 stroops (0.00001 XLM), so:
1 operation: 100 stroops = 0.00001 XLM
10 operations: 1,000 stroops = 0.0001 XLM
100 operations: 10,000 stroops = 0.001 XLM
Sequence Numbers
Each account has a sequence number that must be incremented with each transaction. The transaction's sequence number must be exactly sourceAccount.sequence + 1. After successful execution, the account's sequence number becomes the transaction's sequence number.
See also
Properties
List of operations (1-100)
Transaction preconditions (time/ledger bounds, etc.)
The sequence number for this transaction
List of signatures attached to this transaction.
Soroban transaction data for smart contract operations (optional)
The source account for this transaction (G... or M... address)
Functions
Returns the time bounds defined for the transaction.
Returns true if this is a Soroban transaction.
Returns the signature base - the data that must be signed.
Converts this transaction to its XDR envelope representation.
Returns base64-encoded TransactionEnvelope XDR.