buildUserOperationFromTxs

1function buildUserOperationFromTxs<
2 TTransport,
3 TChain,
4 TAccount,
5 TEntryPointVersion,
6 TContext,
7>(
8 client_,
9 args,
10): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;

Defined in: aa-sdk/core/src/actions/smartAccount/buildUserOperationFromTxs.ts:74

Performs buildUserOperationFromTx in batch and builds into a single, yet to be signed UserOperation (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (to, data, value, maxFeePerGas, maxPriorityFeePerGas) computed using the configured ClientMiddlewares on the SmartAccountClient.

Example

1import type { RpcTransactionRequest } from "viem";
2import { smartAccountClient } from "./smartAccountClient";
3
4const requests: RpcTransactionRequest[] = [
5 {
6 from, // ignored
7 to,
8 data: encodeFunctionData({
9 abi: ContractABI.abi,
10 functionName: "func",
11 args: [arg1, arg2, ...],
12 }),
13 },
14 {
15 from, // ignored
16 to,
17 data: encodeFunctionData({
18 abi: ContractABI.abi,
19 functionName: "func",
20 args: [arg1, arg2, ...],
21 }),
22 },
23];
24const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
25 requests,
26});
27
28// signUserOperation signs the above unsigned user operation struct built
29// using the account connected to the smart account client
30const request = await smartAccountClient.signUserOperation({ uoStruct });
31
32// You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
33// to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
34// EntryPoint contract pointed at by the entryPoint address parameter
35const entryPointAddress = client.account.getEntryPoint().address;
36const uoHash = await smartAccountClient.sendRawUserOperation({
37 request,
38 entryPoint: entryPointAddress,
39});

Type Parameters

Type ParameterDefault type

TTransport extends Transport

Transport

TChain extends undefined | Chain

undefined | Chain

TAccount extends any

any

TEntryPointVersion extends GetEntryPointFromAccount<TAccount>

GetEntryPointFromAccount<TAccount>

TContext extends any

any

Parameters

ParameterTypeDescription

client_

Client<TTransport, TChain, TAccount>

the smart account client to use to make RPC calls

args

BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>

an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware

Returns

Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>

a Promise containing the built user operation