createCallData method
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 transfertransferAmount: 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:
- ArgumentError if the recipient address is invalid
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;
}