# buildUserOperation | @aa-sdk/core

> Overview of the buildUserOperation function from @aa-sdk/core

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

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

Defined in: [aa-sdk/core/src/actions/smartAccount/buildUserOperation.ts:42](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/core/src/actions/smartAccount/buildUserOperation.ts#L42)

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

## Example

```ts
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 Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
      <th align="left">Default type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `TTransport` *extends* [`Transport`](https://viem.sh)
      </td>

      <td>
        [`Transport`](https://viem.sh)
      </td>
    </tr>

    <tr>
      <td>
        `TChain` *extends* `undefined` | [`Chain`](https://viem.sh)
      </td>

      <td>
        `undefined` | [`Chain`](https://viem.sh)
      </td>
    </tr>

    <tr>
      <td>
        `TAccount` *extends*
        | `undefined`
        | [`SmartContractAccount`](../type-aliases/SmartContractAccount)
      </td>

      <td>
        | `undefined`
        | [`SmartContractAccount`](../type-aliases/SmartContractAccount)
      </td>
    </tr>

    <tr>
      <td>
        `TContext` *extends* `any`
      </td>

      <td>
        `any`
      </td>
    </tr>

    <tr>
      <td>
        `TEntryPointVersion` *extends* keyof [`EntryPointRegistryBase`](../interfaces/EntryPointRegistryBase)\<`unknown`>
      </td>

      <td>
        [`GetEntryPointFromAccount`](../type-aliases/GetEntryPointFromAccount)\<`TAccount`>
      </td>
    </tr>

  </tbody>
</table>

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `client_`
      </td>

      <td>
        [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`>
      </td>

      <td>
        the client instance used to build the user operation
      </td>
    </tr>

    <tr>
      <td>
        `args`
      </td>

      <td>
        `BuildUserOperationParameters`\<`TAccount`, `TContext`, `TEntryPointVersion`>
      </td>

      <td>
        the parameters required to build the user operation, including account, overrides, and context
      </td>
    </tr>

  </tbody>
</table>

## Returns

`Promise`\<[`UserOperationStruct`](../type-aliases/UserOperationStruct)\<`TEntryPointVersion`>>

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