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),
]);
Parameter | Type | Status | Description |
---|---|---|---|
to | address | required | The address where the user want to send Tokens. |
value | number | required | The amount of Tokens the user is sending |
data | Function | Encoded 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.