new TransactionBuilder(sourceAccount, optsopt)
Transaction builder helps constructs a new Transaction using the given Account
as the transaction's "source account". The transaction will use the current sequence
number of the given account as its sequence number and increment the given account's
sequence number by one. The given source account must include a private key for signing
the transaction or an error will be thrown.
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 the
sequence number of the source account and include the 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 |
Account
|
The source account for this transaction. |
|||||||||||||||||||||||||||||
opts |
object
|
<optional> |
|