Skip to content
Alchemy Logo

buildUserOperation

function buildUserOperation<
  TTransport,
  TChain,
  TAccount,
  TContext,
  TEntryPointVersion,
>(client_, args): Promise<UserOperationStruct<TEntryPointVersion>>;

Defined in: aa-sdk/core/src/actions/smartAccount/buildUserOperation.ts:42

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

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
});

Type ParameterDefault type

TTransport extends Transport

Transport

TChain extends undefined | Chain

undefined | Chain

TAccount extends | undefined | SmartContractAccount

| undefined | SmartContractAccount

TContext extends any

any

TEntryPointVersion extends keyof EntryPointRegistryBase<unknown>

GetEntryPointFromAccount<TAccount>

ParameterTypeDescription

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

Promise<UserOperationStruct<TEntryPointVersion>>

a promise that resolves to a UserOperationStruct object containing the built user operation details

Was this page helpful?