Class AssembledTransaction<T>

java.lang.Object
org.stellar.sdk.contract.AssembledTransaction<T>

public class AssembledTransaction<T> extends Object
  • 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 builder
      server - the Soroban server
      transactionSigner - the keypair to sign the transaction with
      parseResultXdrFn - the function to parse the result XDR
      submitTimeout - the timeout for submitting the transaction
  • Method Details

    • simulate

      public AssembledTransaction<T> simulate(boolean restore)
      Simulates the transaction on the network. Must be called before signing or submitting the transaction. Will automatically restore required contract state if restore to true 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 failed
      RestorationFailureException - if the contract state could not be restored
    • signAndSubmit

      public T signAndSubmit(@Nullable KeyPair transactionSigner, boolean force)
      Signs and submits the transaction in one step.

      A convenience method combining sign(KeyPair, boolean) and submit().

      Parameters:
      transactionSigner - the keypair to sign the transaction with, or null to use the signer provided in the constructor
      force - 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 raw SCVal
      Throws:
      NotYetSimulatedException - if the transaction has not yet been simulated
      NoSignatureNeededException - if the transaction is a read call, and force is not set to true
      NeedsMoreSignaturesException - if the transaction requires more signatures
      SendTransactionFailedException - if sending the transaction to the network failed
      TransactionStillPendingException - if the transaction is still pending after the timeout
      ExpiredStateException - if the transaction requires restoring contract state
      TransactionFailedException - if the transaction failed
    • sign

      public AssembledTransaction<T> sign(@Nullable KeyPair transactionSigner, boolean force)
      Signs the transaction.
      Parameters:
      transactionSigner - the keypair to sign the transaction with, or null to use the signer provided in the constructor
      force - 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 simulated
      NoSignatureNeededException - if the transaction is a read call, and force is not set to true
      ExpiredStateException - if the transaction requires restoring contract state
      NeedsMoreSignaturesException - if the transaction requires more signatures
    • signAuthEntries

      public AssembledTransaction<T> signAuthEntries(KeyPair authEntriesSigner)
      Signs the transaction's authorization entries.

      An alias for signAuthEntries(KeyPair, Long) with null 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 with
      validUntilLedgerSequence - the ledger sequence number until which the authorization entries are valid, or null to set it to the current ledger sequence + 100
      Returns:
      this AssembledTransaction
      Throws:
      NotYetSimulatedException - if the transaction has not yet been simulated
    • needsNonInvokerSigningBy

      public Set<String> needsNonInvokerSigningBy(boolean includeAlreadySigned)
      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

      public T result() throws NotYetSimulatedException
      Get the result of the function invocation from the simulation.
      Returns:
      The value returned by the invoked function, parsed if parseResultXdrFn was set, otherwise raw SCVal
      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

      public String toEnvelopeXdrBase64()
      Get the transaction envelope XDR.
      Returns:
      The transaction envelope XDR.
    • restoreFootprint

      public void restoreFootprint()
      Restore the contract state.
      Throws:
      TransactionFailedException - if the transaction failed
      TransactionStillPendingException - if the transaction is still pending after the timeout
      SendTransactionFailedException - if sending the transaction to the network failed
    • submit

      public T 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 raw SCVal
      Throws:
      NotYetSimulatedException - if the transaction has not yet been simulated
      SendTransactionFailedException - if sending the transaction to the network failed
      TransactionStillPendingException - if the transaction is still pending after the timeout
      TransactionFailedException - if the transaction failed
    • getBuiltTransaction

      public Transaction getBuiltTransaction()
    • getSimulation

      public SimulateTransactionResponse getSimulation()
    • getSendTransactionResponse

      public SendTransactionResponse getSendTransactionResponse()
    • getGetTransactionResponse

      public GetTransactionResponse getGetTransactionResponse()