Stellar PHP SDK API Documentation

TransactionBuilder
in package

Builds a new Transaction object using the builder pattern

This class provides a fluent interface for constructing Stellar transactions. It manages the source account, operations, memos, preconditions, and fees. The builder pattern allows for method chaining and ensures transactions are properly constructed before submission.

Key Features:

  • Automatic sequence number management
  • Support for multiple operations
  • Flexible fee calculation (per-operation or total)
  • Time bounds and other preconditions
  • Memo attachment

Usage: // Build a simple payment transaction $transaction = (new TransactionBuilder($sourceAccount)) ->addOperation($paymentOperation) ->addMemo(Memo::text("Payment for order #123")) ->setMaxOperationFee(100) ->build();

// Build with time bounds $transaction = (new TransactionBuilder($sourceAccount)) ->addOperation($operation) ->setTimeBounds(new TimeBounds($minTime, $maxTime)) ->build();

// Build with multiple operations $transaction = (new TransactionBuilder($sourceAccount)) ->addOperation($createAccountOp) ->addOperation($paymentOp) ->addOperation($trustlineOp) ->build();

Tags
see
Transaction

The transaction object that is built

see
TransactionBuilderAccount

Interface for source accounts

see
https://developers.stellar.org

Stellar developer docs

since
1.0.0

Table of Contents

Methods

__construct()  : mixed
Construct a new transaction builder.
addMemo()  : TransactionBuilder
Adds a memo to this transaction.
addOperation()  : TransactionBuilder
Adds a new operation to this transaction.
addOperations()  : TransactionBuilder
Adds N new operations to this transaction.
build()  : Transaction
Builds a transaction. It will increment sequence number of the source account.
setIncrementSequenceNumber()  : TransactionBuilder
Allows you to avoid source account and transaction sequence number incrementation, when building the transaction.
setMaxOperationFee()  : TransactionBuilder
Sets the maximal operation fee (base fee) for the transaction.
setPreconditions()  : TransactionBuilder
Adds preconditions to this transaction.
setTimeBounds()  : TransactionBuilder
Adds time bounds to this transaction.

Methods

__construct()

Construct a new transaction builder.

public __construct(TransactionBuilderAccount $sourceAccount) : mixed
Parameters
$sourceAccount : TransactionBuilderAccount

The source account for this transaction. This account is the account who will use a sequence number. When build() is called, the account object's sequence number will be incremented.

setIncrementSequenceNumber()

Allows you to avoid source account and transaction sequence number incrementation, when building the transaction.

public setIncrementSequenceNumber(bool $increment) : TransactionBuilder

If not set to false, it automatically increments it when building the transaction.

Parameters
$increment : bool

false if you would like to suppress sequence number incrementation.

Return values
TransactionBuilder

Builder object so you can chain methods.

setMaxOperationFee()

Sets the maximal operation fee (base fee) for the transaction.

public setMaxOperationFee(int $maxOperationFee) : TransactionBuilder
Parameters
$maxOperationFee : int

maximal operation fee (base fee).

Return values
TransactionBuilder

Builder object so you can chain methods.


        
On this page

Search results