Skip to main content

Send 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.

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 of approve and transfer in a single batch

const approveCallData = ContractUtils.encodeERC20ApproveCall(
spender,
amount
) as unknown as Uint8Array;

const calls = [
{
to: tokenAddress,
value: BigInt(0),
data: approveCallData,
},
{
to: spender,
value: BigInt(0),
data: callData,
},
];

const res = await fuseSDK.executeBatch(calls, txOptions);
console.log(`UserOpHash: ${res?.userOpHash}`);
console.log('Waiting for transaction...');

const receipt = await res?.wait();
console.log('Transaction Hash:', receipt?.transactionHash);