Constructor
new TransactionBuilder(sourceAccount, opts)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sourceAccount |
Account
|
source account for this transaction |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
opts |
object
|
Options object
|
Classes
Methods
addMemo(memo) → {TransactionBuilder}
Adds a memo to the transaction.
Parameters:
Name | Type | Description |
---|---|---|
memo |
Memo
|
Memo object |
Returns:
- Type:
-
TransactionBuilder
addOperation(operation) → {TransactionBuilder}
Adds an operation to the transaction.
Parameters:
Name | Type | Description |
---|---|---|
operation |
xdr.Operation
|
The xdr operation object, use Operation static methods. |
Returns:
- Type:
-
TransactionBuilder
build() → {Transaction}
This will build the transaction. It will also increment the source account's sequence number by 1.
clearOperations() → {TransactionBuilder}
Removes the operations from the builder (useful when cloning).
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) |
Returns:
- Type:
-
TransactionBuilder
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 |
Returns:
- Type:
-
TransactionBuilder
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 |
Returns:
- Type:
-
TransactionBuilder
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 |
Returns:
- Type:
-
TransactionBuilder
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 |
Returns:
- Type:
-
TransactionBuilder
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"). |
Returns:
- Type:
-
TransactionBuilder
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.
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
sorobanData |
xdr.SorobanTransactionData
|
string
|
the xdr.SorobanTransactionData as a raw xdr object or a base64 string to be decoded |
Returns:
- Type:
-
TransactionBuilder
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 |
Returns:
- Type:
-
TransactionBuilder
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.
- Source:
- See:
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. |
Returns:
- Type:
-
TransactionBuilder
(static) buildFeeBumpTransaction(feeSource, baseFee, innerTx, networkPassphrase) → {FeeBumpTransaction}
Builds a FeeBumpTransaction, enabling you to resubmit an existing transaction with a higher fee.
- Source:
- 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.
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) |
Returns:
- Type:
-
FeeBumpTransaction
(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).
- Source:
- To Do:
-
- This cannot clone FeeBumpTransactions, yet.
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 |
Returns:
- Type:
-
TransactionBuilder
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. |
Returns:
- Type:
-
Transaction
|FeeBumpTransaction