transferToken method
Future<ISendUserOperationResponse>
transferToken(
- EthereumAddress tokenAddress,
- EthereumAddress recipientAddress,
- BigInt amount, [
- TxOptions? options,
Transfers a specified amount
of tokens from the user's address to the recipientAddress
.
tokenAddress
- Address of the token contract.
recipientAddress
- Address of the recipient.
amount
- Amount of tokens to transfer.
options
- Additional transaction options.
Implementation
Future<ISendUserOperationResponse> transferToken(
EthereumAddress tokenAddress,
EthereumAddress recipientAddress,
BigInt amount, [
TxOptions? options,
]) async {
Call call;
if (ContractsUtils.isNativeToken(tokenAddress.toString())) {
call = Call(
to: recipientAddress,
value: amount,
data: Uint8List(0),
);
} else {
final callData = ContractsUtils.encodeERC20TransferCall(
tokenAddress,
recipientAddress,
amount,
);
call = Call(
to: tokenAddress,
value: BigInt.zero,
data: callData,
);
}
return _executeUserOperation(call, options);
}