transferWithOptIn method
Directly transfer token from sender to a receiver. The receiver should have opted in to direct transfer.
Implementation
Future<String> transferWithOptIn(
AptosAccount sender,
String creator,
String collectionName,
String tokenName,
BigInt propertyVersion,
String receiver,
BigInt amount, {
BigInt? maxGasAmount,
BigInt? gasUnitPrice,
BigInt? expireTimestamp
}) {
// compile script to invoke public transfer function
final payload = TransactionPayloadScript(
Script(
HexString(TOKEN_TRANSFER_OPT_IN).toUint8Array(),
[],
[
TransactionArgumentAddress(AccountAddress.fromHex(creator)),
TransactionArgumentU8Vector(Uint8List.fromList(utf8.encode(collectionName))),
TransactionArgumentU8Vector(Uint8List.fromList(utf8.encode(tokenName))),
TransactionArgumentU64(propertyVersion),
TransactionArgumentAddress(AccountAddress.fromHex(receiver)),
TransactionArgumentU64(amount),
],
),
);
return aptosClient.generateSignSubmitTransaction(
sender,
payload,
maxGasAmount: maxGasAmount,
gasUnitPrice: gasUnitPrice,
expireTimestamp: expireTimestamp
);
}