buildUserOperation

Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.

Import

1import { buildUserOperation } from "@aa-sdk/core";

Usage

1import { createSmartAccountClient } from "@aa-sdk/core";
2
3// smart account client is already extended with buildUserOperation
4const client = createSmartAccountClient(...);
5const result = await client.buildUserOperation({
6uo: {
7target: "0x...",
8data: "0x...", // or "0x",
9value: 0n, // optional
10},
11account, // only required if the client above is not connected to an account
12});

Parameters

client_

Client<TTransport, TChain, TAccount> the client instance used to build the user operation

args

BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion> the parameters required to build the user operation, including account, overrides, and context

Returns

Promise<UserOperationStruct<TEntryPointVersion>> a promise that resolves to a UserOperationStruct object containing the built user operation details