buildUserOperation
Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
Import
import { buildUserOperation } from "@aa-sdk/core";
Usage
import { createSmartAccountClient } from "@aa-sdk/core";
// smart account client is already extended with buildUserOperation
const client = createSmartAccountClient(...);
const result = await client.buildUserOperation({
uo: {
target: "0x...",
data: "0x...", // or "0x",
value: 0n, // optional
},
account, // only required if the client above is not connected to an account
});
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