addRecipient method

Transaction addRecipient(
  1. String to, {
  2. String? action,
  3. List<Object>? args,
})

Add recipient to the transaction (with a named action)

  • to : Recipient address (hexadecimal)
  • action : The named action
  • args : The arguments list for the named action (can only contain JSON valid data)

Implementation

Transaction addRecipient(
  String to, {
  String? action,
  List<Object>? args,
}) {
  if (!isHex(to)) {
    throw const FormatException("'to' must be an hexadecimal string");
  }

  final newRecipient = data!.recipients.toList()
    ..add(Recipient(address: to, action: action, args: args));
  return copyWith.data!(
    recipients: newRecipient,
  );
}