Package org.stellar.sdk.contract
Class AssembledTransaction<T>
java.lang.Object
org.stellar.sdk.contract.AssembledTransaction<T>
-
Constructor Summary
ConstructorsConstructorDescriptionAssembledTransaction
(TransactionBuilder transactionBuilder, SorobanServer server, KeyPair transactionSigner, Function<SCVal, T> parseResultXdrFn, int submitTimeout) Creates a new AssembledTransaction. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if the transaction is a read call.needsNonInvokerSigningBy
(boolean includeAlreadySigned) Get the addresses that need to sign the authorization entries.void
Restore the contract state.result()
Get the result of the function invocation from the simulation.Signs the transaction.signAndSubmit
(KeyPair transactionSigner, boolean force) Signs and submits the transaction in one step.signAuthEntries
(KeyPair authEntriesSigner) Signs the transaction's authorization entries.signAuthEntries
(KeyPair authEntriesSigner, Long validUntilLedgerSequence) Signs the transaction's authorization entries.simulate
(boolean restore) Simulates the transaction on the network.submit()
Submits the transaction to the network.Get the transaction envelope XDR.
-
Constructor Details
-
AssembledTransaction
public AssembledTransaction(TransactionBuilder transactionBuilder, SorobanServer server, @Nullable KeyPair transactionSigner, @Nullable Function<SCVal, T> parseResultXdrFn, int submitTimeout) Creates a new AssembledTransaction.- Parameters:
transactionBuilder
- the transaction builderserver
- the Soroban servertransactionSigner
- the keypair to sign the transaction withparseResultXdrFn
- the function to parse the result XDRsubmitTimeout
- the timeout for submitting the transaction
-
-
Method Details
-
simulate
Simulates the transaction on the network. Must be called before signing or submitting the transaction. Will automatically restore required contract state ifrestore
totrue
and this is not a read call.- Parameters:
restore
- whether to automatically restore contract state if needed- Returns:
- this AssembledTransaction
- Throws:
SimulationFailedException
- if the simulation failedRestorationFailureException
- if the contract state could not be restored
-
signAndSubmit
Signs and submits the transaction in one step.A convenience method combining
sign(KeyPair, boolean)
andsubmit()
.- Parameters:
transactionSigner
- the keypair to sign the transaction with, ornull
to use the signer provided in the constructorforce
- whether to sign and submit even if the transaction is a read call- Returns:
- The value returned by the invoked function, parsed if
parseResultXdrFn
was set, otherwise rawSCVal
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulatedNoSignatureNeededException
- if the transaction is a read call, andforce
is not set totrue
NeedsMoreSignaturesException
- if the transaction requires more signaturesSendTransactionFailedException
- if sending the transaction to the network failedTransactionStillPendingException
- if the transaction is still pending after the timeoutExpiredStateException
- if the transaction requires restoring contract stateTransactionFailedException
- if the transaction failed
-
sign
Signs the transaction.- Parameters:
transactionSigner
- the keypair to sign the transaction with, ornull
to use the signer provided in the constructorforce
- whether to sign and submit even if the transaction is a read call- Returns:
- this AssembledTransaction
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulatedNoSignatureNeededException
- if the transaction is a read call, andforce
is not set totrue
ExpiredStateException
- if the transaction requires restoring contract stateNeedsMoreSignaturesException
- if the transaction requires more signatures
-
signAuthEntries
Signs the transaction's authorization entries.An alias for
signAuthEntries(KeyPair, Long)
withnull
as the second argument.- Parameters:
authEntriesSigner
- the keypair to sign the authorization entries with- Returns:
- this AssembledTransaction
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulated
-
signAuthEntries
public AssembledTransaction<T> signAuthEntries(KeyPair authEntriesSigner, @Nullable Long validUntilLedgerSequence) Signs the transaction's authorization entries.- Parameters:
authEntriesSigner
- the keypair to sign the authorization entries withvalidUntilLedgerSequence
- the ledger sequence number until which the authorization entries are valid, ornull
to set it to the current ledger sequence + 100- Returns:
- this AssembledTransaction
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulated
-
needsNonInvokerSigningBy
Get the addresses that need to sign the authorization entries.- Parameters:
includeAlreadySigned
- whether to include addresses that have already signed the authorization entries- Returns:
- The addresses that need to sign the authorization entries.
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulated
-
result
Get the result of the function invocation from the simulation.- Returns:
- The value returned by the invoked function, parsed if
parseResultXdrFn
was set, otherwise rawSCVal
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulated
-
isReadCall
public boolean isReadCall()Check if the transaction is a read call.- Returns:
true
if the transaction is a read call,false
otherwise- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulated
-
toEnvelopeXdrBase64
Get the transaction envelope XDR.- Returns:
- The transaction envelope XDR.
-
restoreFootprint
public void restoreFootprint()Restore the contract state.- Throws:
TransactionFailedException
- if the transaction failedTransactionStillPendingException
- if the transaction is still pending after the timeoutSendTransactionFailedException
- if sending the transaction to the network failed
-
submit
Submits the transaction to the network.It will send the transaction to the network and wait for the result.
- Returns:
- The value returned by the invoked function, parsed if
parseResultXdrFn
was set, otherwise rawSCVal
- Throws:
NotYetSimulatedException
- if the transaction has not yet been simulatedSendTransactionFailedException
- if sending the transaction to the network failedTransactionStillPendingException
- if the transaction is still pending after the timeoutTransactionFailedException
- if the transaction failed
-
getBuiltTransaction
-
getSimulation
-
getSendTransactionResponse
-
getGetTransactionResponse
-