Class AtomicTransactionComposer

A class used to construct and execute atomic transaction groups

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

  • 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: {
          appAccounts?: (string | Address)[];
          appForeignApps?: (number | bigint)[];
          appForeignAssets?: (number | bigint)[];
          appID: number | bigint;
          approvalProgram?: Uint8Array;
          boxes?: BoxReference[];
          clearProgram?: Uint8Array;
          extraPages?: number;
          lease?: Uint8Array;
          method: ABIMethod;
          methodArgs?: ABIArgument[];
          note?: Uint8Array;
          numGlobalByteSlices?: number;
          numGlobalInts?: number;
          numLocalByteSlices?: number;
          numLocalInts?: number;
          onComplete?: OnApplicationComplete;
          rekeyTo?: string | Address;
          sender: string | Address;
          signer: TransactionSigner;
          suggestedParams: SuggestedParams;
      }
      • Optional appAccounts?: (string | Address)[]

        Array of Address strings that represent external accounts supplied to this application. If accounts are provided here, the accounts specified in the method args will appear after these.

      • Optional appForeignApps?: (number | bigint)[]

        Array of App ID numbers that represent external apps supplied to this application. If apps are provided here, the apps specified in the method args will appear after these.

      • Optional appForeignAssets?: (number | bigint)[]

        Array of Asset ID numbers that represent external assets supplied to this application. If assets are provided here, the assets specified in the method args will appear after these.

      • appID: number | bigint

        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 boxes?: BoxReference[]

        The box references for this application call

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

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

      • sender: string | Address

        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

  • Get the number of transactions currently in this atomic group.

    Returns number

  • 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: bigint;
        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.

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

  • Simulates the transaction group in the network.

    The composer will try to sign any transactions in the group, then simulate the results. Simulating the group will not change the composer's status.

    Parameters

    • client: Algodv2

      An Algodv2 client

    • Optional request: SimulateRequest

      SimulateRequest with options in simulation. If provided, the request's transaction group will be overrwritten by the composer's group, only simulation related options will be used.

    Returns Promise<{
        methodResults: ABIResult[];
        simulateResponse: SimulateResponse;
    }>

    A promise that, upon success, resolves to an object containing an array of results containing one element for each method call transaction in this group (ABIResult[]) and the SimulateResponse object.

  • 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