Skip to main content

Send Batch Transactions

Batch Transactions

A batch refers to a group of calls inside a single user operation. This can be an approve and send transaction in one call. The executeBatch() method is used.

The executeBatch() method takes in an array of Call(). With each method taking in 3 keys: to, value and data.

executeBatch([
Call(to: to, value: value, data: data),
Call(to: to, value: value, data: data),
Call(to: to, value: value, data: data),
]);
ParameterTypeStatusDescription
toaddressrequiredThe address where the user want to send Tokens.
valuenumberrequiredThe amount of Tokens the user is sending
dataFunctionEncoded Function Data for Smart Contract Methods

Example approve_and_transfer.dart

final tokenAddress = EthereumAddress.fromHex('TOKEN_ADDRESS');
final recipientAddress = EthereumAddress.fromHex('RECIPIENT_ADDRESS');
final amountInWei = BigInt.parse('AMOUNT_IN_WEI');

final res = await fuseSDK.executeBatch(
[
// Approve ERC20 Token call
Call(
to: tokenAddress,
value: BigInt.zero,
data: ContractsUtils.encodeERC20ApproveCall(
tokenAddress,
recipientAddress,
amountInWei,
),
),
// Transfer ERC20 Token call
Call(
to: tokenAddress,
value: BigInt.zero,
data: ContractsUtils.encodeERC20TransferCall(
tokenAddress,
recipientAddress,
amountInWei,
),
),
],
);

Code example

For more code examples on using the Fuse Wallet SDK for Flutter for Batch Transfer, you can check out the official Flutter SDK repository.

Was this page helpful?