Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AtomicTransactionComposer

A class used to construct and execute atomic transaction groups

Hierarchy

  • AtomicTransactionComposer

Index

Constructors

Properties

methodCalls: Map<number, ABIMethod> = ...
signedTxns: Uint8Array[] = []
status: AtomicTransactionComposerStatus = AtomicTransactionComposerStatus.BUILDING
transactions: TransactionWithSigner[] = []
txIDs: string[] = []
MAX_GROUP_SIZE: number = 16

The maximum size of an atomic transaction group.

Methods

  • addMethodCall(__namedParameters: { appID: number; approvalProgram?: Uint8Array; clearProgram?: Uint8Array; extraPages?: number; lease?: Uint8Array; method: ABIMethod; methodArgs?: ABIArgument[]; note?: Uint8Array; numGlobalByteSlices?: number; numGlobalInts?: number; numLocalByteSlices?: number; numLocalInts?: number; onComplete?: OnApplicationComplete; rekeyTo?: string; sender: string; signer: TransactionSigner; suggestedParams: SuggestedParams }): void
  • 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.

    Parameters

    • __namedParameters: { appID: number; approvalProgram?: Uint8Array; clearProgram?: Uint8Array; extraPages?: number; lease?: Uint8Array; method: ABIMethod; methodArgs?: ABIArgument[]; note?: Uint8Array; numGlobalByteSlices?: number; numGlobalInts?: number; numLocalByteSlices?: number; numLocalInts?: number; onComplete?: OnApplicationComplete; rekeyTo?: string; sender: string; signer: TransactionSigner; suggestedParams: SuggestedParams }
      • appID: number

        The ID of the smart contract to call. Set this to 0 to indicate an application creation call.

      • Optional approvalProgram?: Uint8Array

        The approval program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC

      • Optional clearProgram?: Uint8Array

        The clear program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC

      • Optional extraPages?: number

        The number of extra pages to allocate for the application's programs. Only set this if this is an application creation call. If omitted, defaults to 0.

      • Optional lease?: Uint8Array

        The lease value for this application call

      • method: ABIMethod

        The method to call on the smart contract

      • Optional methodArgs?: ABIArgument[]

        The arguments to include in the method call. If omitted, no arguments will be passed to the method.

      • Optional note?: Uint8Array

        The note value for this application call

      • Optional numGlobalByteSlices?: number

        The global byte slice schema size. Only set this if this is an application creation call.

      • Optional numGlobalInts?: number

        The global integer schema size. Only set this if this is an application creation call.

      • Optional numLocalByteSlices?: number

        The local byte slice schema size. Only set this if this is an application creation call.

      • Optional numLocalInts?: number

        The local integer schema size. Only set this if this is an application creation call.

      • Optional onComplete?: OnApplicationComplete

        The OnComplete action to take for this application call. If omitted, OnApplicationComplete.NoOpOC will be used.

      • Optional rekeyTo?: string

        If provided, the address that the sender will be rekeyed to at the conclusion of this application call

      • sender: string

        The address of the sender of this application call

      • signer: TransactionSigner

        A transaction signer that can authorize this application call from sender

      • suggestedParams: SuggestedParams

        Transactions params to use for this application call

    Returns void

  • Add a transaction to this atomic group.

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

    Parameters

    Returns void

  • Finalize the transaction group and returned the finalized transactions.

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

    Returns TransactionWithSigner[]

  • 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.

    Returns AtomicTransactionComposer

  • count(): number
  • Get the number of transactions currently in this atomic group.

    Returns number

  • execute(client: Algodv2, waitRounds: number): Promise<{ confirmedRound: number; methodResults: ABIResult[]; txIDs: string[] }>
  • 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.

    Parameters

    • client: Algodv2

      An Algodv2 client

    • waitRounds: number

      The maximum number of rounds to wait for transaction confirmation

    Returns Promise<{ confirmedRound: number; methodResults: ABIResult[]; txIDs: string[] }>

    A promise that, upon success, resolves to an object containing the confirmed round for this transaction, the txIDs of the submitted transactions, and an array of results containing one element for each method call transaction in this group.

  • gatherSignatures(): Promise<Uint8Array[]>
  • 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 Promise<Uint8Array[]>

    A promise that resolves to an array of signed transactions.

  • submit(client: Algodv2): Promise<string[]>
  • 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.

    Parameters

    Returns Promise<string[]>

    A promise that, upon success, resolves to a list of TxIDs of the submitted transactions.

Generated using TypeDoc