addMethodCall method

Future<void> addMethodCall(
  1. 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 {@link com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder}

Implementation

Future<void> addMethodCall(MethodCallParams methodCall) async {
  if (status != AtcStatus.BUILDING) {
    throw ArgumentError(
        'Atomic Transaction Composer must be in BUILDING stage');
  }

  final txns = await methodCall.createTransactions();
  if (transactions.length + txns.length > MAX_GROUP_SIZE) {
    throw ArgumentError(
        'Atomic Transaction Composer cannot exceed $MAX_GROUP_SIZE transactions');
  }

  transactions.addAll(txns);
  methodMap[transactions.length - 1] = methodCall.method;
}