createCallData method

Uint8List createCallData({
  1. required String recipientAddress,
  2. required BigInt transferAmount,
  3. bool keepAlive = true,
})

Creates SCALE-encoded call data for a balance transfer operation.

This method generates the encoded call data that can be used in multisig transactions for transferring funds from the multisig account to a recipient.

Parameters:

  • recipientAddress: The destination address for the transfer
  • transferAmount: The amount to transfer (in smallest units)
  • keepAlive: If true, uses transferKeepAlive to ensure sender stays above existential deposit (default: true)

Returns: A Uint8List containing the SCALE-encoded call data.

Throws:

Example:

final callData = multisig.createCallData(
  recipientAddress: bob.address,
  transferAmount: BigInt.from(500000000000),
  keepAlive: true,
);

Implementation

Uint8List createCallData({
  required final String recipientAddress,
  required final BigInt transferAmount,
  final bool keepAlive = true,
}) {
  late final RuntimeCall call;
  final recipient = Address.decode(recipientAddress).pubkey;
  if (keepAlive) {
    call = Balances.transferKeepAlive
        .toAccountId(amount: transferAmount, destination: recipient)
        .toRuntimeCall(chainInfo);
  } else {
    call = Balances.transfer
        .toAccountId(amount: transferAmount, destination: recipient)
        .toRuntimeCall(chainInfo);
  }
  final callData = chainInfo.callsCodec.encode(call);
  return callData;
}