Class TransactionBuilder
-
Constructor Summary
ConstructorDescriptionTransactionBuilder
(@NonNull TransactionBuilderAccount sourceAccount, @NonNull Network network) Construct a new transaction builder. -
Method Summary
Modifier and TypeMethodDescriptionAdds a memo to this transaction.addOperation
(@NonNull Operation operation) Adds a new operation to this transaction.addOperations
(@NonNull Collection<Operation> operations) Adds operation to this transaction.addPreconditions
(@NonNull TransactionPreconditions preconditions) Adds preconditions.build()
Builds a transaction and increments the sequence number on the source account after transaction is constructed.int
setBaseFee
(long baseFee) setSorobanData
(String sorobanData) Sets the transaction's internal Soroban transaction data (resources, footprint, etc.).setSorobanData
(SorobanTransactionData sorobanData) Sets the transaction's internal Soroban transaction data (resources, footprint, etc.).setTimeout
(long timeout) An alias forsetTimeout(BigInteger)
withtimeout
in seconds.setTimeout
(BigInteger timeout) 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.
-
Constructor Details
-
TransactionBuilder
public TransactionBuilder(@NonNull @NonNull TransactionBuilderAccount sourceAccount, @NonNull @NonNull Network network) Construct a new transaction builder.- Parameters:
sourceAccount
- 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.network
- the testnet or pubnet network to use
-
-
Method Details
-
getOperationsCount
public int getOperationsCount() -
addOperation
Adds a new operation to this transaction.- Parameters:
operation
- the operation to add- Returns:
- Builder object so you can chain methods.
- See Also:
-
addOperations
Adds operation to this transaction.- Parameters:
operations
- list of operations- Returns:
- Builder object so you can chain methods.
- See Also:
-
addPreconditions
public TransactionBuilder addPreconditions(@NonNull @NonNull TransactionPreconditions preconditions) Adds preconditions. For details of all preconditions on transaction refer to CAP-21- Parameters:
preconditions
- the tx PreConditions- Returns:
- updated Builder object
-
addMemo
Adds a memo to this transaction.- Parameters:
memo
- memo to add- Returns:
- Builder object so you can chain methods.
- See Also:
-
setTimeout
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 theTimeBounds
withmaxTime
on the transaction (this is whatsetTimeout
does internally; if there'sminTime
set but nomaxTime
it will be added). Call toBuilder.setTimeout
is required if Transaction does not havemax_time
set. If you don't want to set timeout, useTIMEOUT_INFINITE
. In general, you should setTIMEOUT_INFINITE
only in smart contracts. Please note that Horizon may still return504 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:
timeout
- Timeout in seconds.- Returns:
- updated Builder
- See Also:
-
setTimeout
An alias forsetTimeout(BigInteger)
withtimeout
in seconds.- Parameters:
timeout
- Timeout in seconds.- Returns:
- updated Builder
-
setBaseFee
-
build
Builds a transaction and increments the sequence number on the source account after transaction is constructed. -
setSorobanData
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
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.InvokeHostFunctionOperation
, providing necessary resource and storage footprint estimations for contract invocation.- Parameters:
sorobanData
- Soroban data to set- Returns:
- Builder object so you can chain methods.
-
setSorobanData
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
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.InvokeHostFunctionOperation
, providing necessary resource and storage footprint estimations for contract invocation.- Parameters:
sorobanData
- Soroban data to set- Returns:
- Builder object so you can chain methods.
-