TransactionBuilder

TransactionBuilder

new TransactionBuilder(sourceAccount, optsopt)

Transaction builder helps constructs a new Transaction using the given account id

Operations can be added to the transaction via their corresponding builder methods, and each returns the TransactionBuilder object so they can be chained together. After adding the desired operations, call the build() method on the TransactionBuilder to return a fully constructed Transaction that can be signed. The returned transaction will contain signature from the source account.

The following code example creates a new transaction with Operation.createAccount and Operation.payment operations. The Transaction's source account first funds destinationA, then sends a payment to destinationB. The built transaction is then signed by sourceKeypair.

var transaction = new TransactionBuilder(source)
  .addOperation(Operation.createAccount({
          destination: destinationA,
          startingBalance: "20"
      }) // <- funds and creates destinationA
      .addOperation(Operation.payment({
          destination: destinationB,
          amount: "100"
          asset: Asset.native()
      }) // <- sends 100 XLM to destinationB
  .build();

transaction.sign(sourceKeypair);
Source:
Parameters:
Name Type Attributes Description
sourceAccount string

The source account for this transaction.

opts object <optional>
Name Type Attributes Description
fee number <optional>

The max fee willing to pay per operation in this transaction (in stroops).

timeBounds object <optional>

The timeBounds for the validity of this transaction.

Name Type Attributes Description
minTime string <optional>

64 bit unix timestamp

maxTime string <optional>

64 bit unix timestamp

memo Memo <optional>

The memo for the transaction