Class AtomicTransactionComposer


  • public class AtomicTransactionComposer
    extends Object
    • Constructor Detail

      • AtomicTransactionComposer

        public AtomicTransactionComposer()
    • Method Detail

      • getCount

        public int getCount()
        Get the number of transactions currently in this atomic group.
      • cloneComposer

        public AtomicTransactionComposer cloneComposer()
                                                throws IOException
        Create a new composer with the same underlying transactions. The new composer's status will be BUILDING, so additional transactions may be added to it.
        Throws:
        IOException
      • addTransaction

        public void addTransaction​(TransactionWithSigner txnAndSigner)
        Add a transaction to this atomic group.

        An error will be thrown if the composer's status is not BUILDING, or if adding this transaction causes the current group to exceed MAX_GROUP_SIZE.

      • addMethodCall

        public void addMethodCall​(MethodCallParams methodCall)
        Add a smart contract method call to this atomic group.

        An error will be thrown if the composer's status is not BUILDING, if adding this transaction causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid for the given method.

        For help creating a MethodCallParams object, see MethodCallTransactionBuilder

      • buildGroup

        public List<TransactionWithSigner> buildGroup()
                                               throws IOException
        Finalize the transaction group and returned the finalized transactions.

        The composer's status will be at least BUILT after executing this method.

        Throws:
        IOException
      • gatherSignatures

        public List<SignedTransaction> gatherSignatures()
                                                 throws Exception
        Obtain signatures for each transaction in this group. If signatures have already been obtained, this method will return cached versions of the signatures.

        The composer's status will be at least SIGNED after executing this method.

        An error will be thrown if signing any of the transactions fails.

        Returns:
        an array of signed transactions.
        Throws:
        Exception
      • submit

        public List<String> submit​(AlgodClient client)
                            throws Exception
        Send the transaction group to the network, but don't wait for it to be committed to a block. An error will be thrown if submission fails.

        The composer's status must be SUBMITTED or lower before calling this method. If submission is successful, this composer's status will update to SUBMITTED.

        Note: a group can only be submitted again if it fails.

        Returns:
        If the submission is successful, resolves to a list of TxIDs of the submitted transactions.
        Throws:
        Exception
      • execute

        public AtomicTransactionComposer.ExecuteResult execute​(AlgodClient client,
                                                               int waitRounds)
                                                        throws Exception
        Send the transaction group to the network and wait until it's committed to a block. An error will be thrown if submission or execution fails.

        The composer's status must be SUBMITTED or lower before calling this method, since execution is only allowed once. If submission is successful, this composer's status will update to SUBMITTED. If the execution is also successful, this composer's status will update to COMMITTED.

        Note: a group can only be submitted again if it fails.

        Returns:
        If the execution is successful, resolves to an object containing the confirmed round for this transaction, the txIDs of the submitted transactions, an array of results containing one element for each method call transaction in this group, and the raw transaction response from algod. If a method has no return value (void), then the method results array will contain null for that return value.
        Throws:
        Exception