# new TransactionBuilder(sourceAccount, opts)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sourceAccount |
Account
|
source account for this transaction |
|
opts |
object
|
Options object |
|
fee |
string
|
max fee you're willing to pay per operation in this transaction (in stroops) |
|
timebounds |
object
|
<optional> |
timebounds for the validity of this transaction |
timebounds.minTime |
number
|
string
|
Date
|
<optional> |
64-bit UNIX timestamp or Date object |
timebounds.maxTime |
number
|
string
|
Date
|
<optional> |
64-bit UNIX timestamp or Date object |
ledgerbounds |
object
|
<optional> |
ledger bounds for the validity of this transaction |
ledgerbounds.minLedger |
number
|
<optional> |
number of the minimum ledger sequence |
ledgerbounds.maxLedger |
number
|
<optional> |
number of the maximum ledger sequence |
minAccountSequence |
string
|
<optional> |
number for the minimum account sequence |
minAccountSequenceAge |
number
|
<optional> |
number of seconds for the minimum account sequence age |
minAccountSequenceLedgerGap |
number
|
<optional> |
number of ledgers for the minimum account sequence ledger gap |
extraSigners |
Array.<string>
|
<optional> |
list of the extra signers required for this transaction |
memo |
Memo
|
<optional> |
memo for the transaction |
networkPassphrase |
string
|
<optional> |
passphrase of the target Stellar network (e.g. "Public Global Stellar Network ; September 2015" for the pubnet) |
sorobanData |
xdr.SorobanTransactionData
|
string
|
<optional> |
an
optional instance of xdr.SorobanTransactionData to be set as the
internal |
Classes
Methods
# addOperation(operation) → {TransactionBuilder}
Adds an operation to the transaction.
Parameters:
Name | Type | Description |
---|---|---|
operation |
xdr.Operation
|
The xdr operation object, use Operation static methods. |
# addOperationAt(operation, index) → {TransactionBuilder}
Adds an operation to the transaction at a specific index.
Parameters:
Name | Type | Description |
---|---|---|
operation |
xdr.Operation
|
The xdr operation object to add, use Operation static methods. |
index |
number
|
The index at which to insert the operation. |
- The TransactionBuilder instance for method chaining.
# build() → {Transaction}
This will build the transaction. It will also increment the source account's sequence number by 1.
This method will return the built Transaction.
# clearOperationAt(index) → {TransactionBuilder}
Removes the operation at the specified index from the transaction.
Parameters:
Name | Type | Description |
---|---|---|
index |
number
|
The index of the operation to remove. |
The TransactionBuilder instance for method chaining.
# clearOperations() → {TransactionBuilder}
Removes the operations from the builder (useful when cloning).
this builder instance
# setExtraSigners(extraSigners) → {TransactionBuilder}
For the transaction to be valid, there must be a signature corresponding to
every Signer in this array, even if the signature is not otherwise required
by the sourceAccount or operations. Internally this will set the
extraSigners
precondition.
Parameters:
Name | Type | Description |
---|---|---|
extraSigners |
Array.<string>
|
required extra signers (as StrKeys) |
# setLedgerbounds(minLedger, maxLedger) → {TransactionBuilder}
If you want to prepare a transaction which will only be valid within some
range of ledgers, you can set a ledgerbounds precondition.
Internally this will set the minLedger
and maxLedger
preconditions.
Parameters:
Name | Type | Description |
---|---|---|
minLedger |
number
|
The minimum ledger this transaction is valid at
or after. Cannot be negative. If the value is |
maxLedger |
number
|
The maximum ledger this transaction is valid
before. Cannot be negative. If the value is |
# setMinAccountSequence(minAccountSequence) → {TransactionBuilder}
If you want to prepare a transaction which will be valid only while the account sequence number is
minAccountSequence <= sourceAccountSequence < tx.seqNum
Note that after execution the account's sequence number is always raised to
tx.seqNum
. Internally this will set the minAccountSequence
precondition.
Parameters:
Name | Type | Description |
---|---|---|
minAccountSequence |
string
|
The minimum source account sequence
number this transaction is valid for. If the value is |
# setMinAccountSequenceAge(durationInSeconds) → {TransactionBuilder}
For the transaction to be valid, the current ledger time must be at least
minAccountSequenceAge
greater than sourceAccount's sequenceTime
.
Internally this will set the minAccountSequenceAge
precondition.
Parameters:
Name | Type | Description |
---|---|---|
durationInSeconds |
number
|
The minimum amount of time between
source account sequence time and the ledger time when this transaction
will become valid. If the value is |
# setMinAccountSequenceLedgerGap(gap) → {TransactionBuilder}
For the transaction to be valid, the current ledger number must be at least
minAccountSequenceLedgerGap
greater than sourceAccount's ledger sequence.
Internally this will set the minAccountSequenceLedgerGap
precondition.
Parameters:
Name | Type | Description |
---|---|---|
gap |
number
|
The minimum number of ledgers between source account
sequence and the ledger number when this transaction will become valid.
If the value is |
# setNetworkPassphrase(networkPassphrase) → {TransactionBuilder}
Set network nassphrase for the Transaction that will be built.
Parameters:
Name | Type | Description |
---|---|---|
networkPassphrase |
string
|
passphrase of the target Stellar network (e.g. "Public Global Stellar Network ; September 2015"). |
# setSorobanData(sorobanData) → {TransactionBuilder}
Sets the transaction's internal Soroban transaction data (resources, footprint, etc.).
For non-contract(non-Soroban) transactions, this setting has no effect. In the case of Soroban transactions, this is either an instance of xdr.SorobanTransactionData or a base64-encoded string of said structure. This is usually obtained from the simulation response based on a transaction with a Soroban operation (e.g. Operation.invokeHostFunction, providing necessary resource and storage footprint estimations for contract invocation.
Parameters:
Name | Type | Description |
---|---|---|
sorobanData |
xdr.SorobanTransactionData
|
string
|
the xdr.SorobanTransactionData as a raw xdr object or a base64 string to be decoded |
# setTimebounds(minEpochOrDate, maxEpochOrDate) → {TransactionBuilder}
If you want to prepare a transaction which will become valid at some point
in the future, or be invalid after some time, you can set a timebounds
precondition. Internally this will set the minTime
, and maxTime
preconditions. Conflicts with setTimeout
, so use one or the other.
Parameters:
Name | Type | Description |
---|---|---|
minEpochOrDate |
Date
|
number
|
Either a JS Date object, or a number
of UNIX epoch seconds. The transaction is valid after this timestamp.
Can't be negative. If the value is |
maxEpochOrDate |
Date
|
number
|
Either a JS Date object, or a number
of UNIX epoch seconds. The transaction is valid until this timestamp.
Can't be negative. If the value is |
# setTimeout(timeoutSeconds) → {TransactionBuilder}
Sets a timeout precondition on the transaction.
Because of the distributed nature of the Stellar network it is possible
that the status of your transaction will be determined after a long time
if the network is highly congested. If you want to be sure to receive the
status of the transaction within a given period you should set the TimeBounds with maxTime
on the transaction (this is what setTimeout
does internally; if there's minTime
set but no maxTime
it will be
added).
A call to TransactionBuilder.setTimeout
is required if Transaction
does not have max_time
set. If you don't want to set timeout, use
TimeoutInfinite
. In general you should set TimeoutInfinite
only in smart contracts.
Please note that Horizon may still return 504 Gateway Timeout
error, even for short timeouts. In such case you need to resubmit the same
transaction again without making any changes to receive a status. This
method is using the machine system time (UTC), make sure it is set
correctly.
Parameters:
Name | Type | Description |
---|---|---|
timeoutSeconds |
number
|
Number of seconds the transaction is good. Can't be negative. If the value is TimeoutInfinite, the transaction is good indefinitely. |
# static buildFeeBumpTransaction(feeSource, baseFee, innerTx, networkPassphrase) → {FeeBumpTransaction}
Builds a FeeBumpTransaction, enabling you to resubmit an existing transaction with a higher fee.
Parameters:
Name | Type | Description |
---|---|---|
feeSource |
Keypair
|
string
|
account paying for the transaction,
in the form of either a Keypair (only the public key is used) or
an account ID (in G... or M... form, but refer to |
baseFee |
string
|
max fee willing to pay per operation in inner transaction (in stroops) |
innerTx |
Transaction
|
Transaction to be bumped by the fee bump transaction |
networkPassphrase |
string
|
passphrase of the target Stellar network (e.g. "Public Global Stellar Network ; September 2015", see Networks) |
- See:
- To Do:
-
- Alongside the next major version bump, this type signature can be changed to be less awkward: accept a MuxedAccount as the `feeSource` rather than a keypair or string.
View Source js-stellar-base/src/transaction_builder.js, line 717
# static cloneFrom(tx, optsopt) → {TransactionBuilder}
Creates a builder instance using an existing Transaction as a template, ignoring any existing envelope signatures.
Note that the sequence number WILL be cloned, so EITHER this transaction or the one it was cloned from will be valid. This is useful in situations where you are constructing a transaction in pieces and need to make adjustments as you go (for example, when filling out Soroban resource information).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
Transaction
|
a "template" transaction to clone exactly |
|
opts |
object
|
<optional> |
additional options to override the clone, e.g.
{fee: '1000'} will override the existing base fee derived from |
- To Do:
-
- This cannot clone FeeBumpTransactions, yet.
View Source js-stellar-base/src/transaction_builder.js, line 179
a "prepared" builder instance with the same configuration and operations as the given transaction
# static fromXDR(envelope, networkPassphrase) → {Transaction|FeeBumpTransaction}
Build a Transaction or FeeBumpTransaction from an xdr.TransactionEnvelope.
Parameters:
Name | Type | Description |
---|---|---|
envelope |
string
|
xdr.TransactionEnvelope
|
The transaction envelope object or base64 encoded string. |
networkPassphrase |
string
|
The network passphrase of the target Stellar network (e.g. "Public Global Stellar Network ; September 2015"), see Networks. |