# UserOperation.toTypedData

Converts a signed [`UserOperation.UserOperation`](/ercs/erc4337/UserOperation/types#useroperation) to a [`TypedData.Definition`](/api/TypedData/types#definition).

## Imports

:::code-group
```ts [Named]
import { UserOperation } from 'ox/erc4337'
```

```ts [Entrypoint]
import * as UserOperation from 'ox/erc4337/UserOperation'
```
:::

## Examples

```ts twoslash
import { Value } from 'ox'
import { UserOperation } from 'ox/erc4337'

const typedData = UserOperation.toTypedData(
  {
    authorization: {
      chainId: 1,
      address: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
      nonce: 69n,
      yParity: 0,
      r: '0x0000000000000000000000000000000000000000000000000000000000000001',
      s: '0x0000000000000000000000000000000000000000000000000000000000000002'
    },
    callData: '0xdeadbeef',
    callGasLimit: 300_000n,
    maxFeePerGas: Value.fromGwei('20'),
    maxPriorityFeePerGas: Value.fromGwei('2'),
    nonce: 69n,
    preVerificationGas: 100_000n,
    sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
    signature: '0x...',
    verificationGasLimit: 100_000n
  },
  {
    chainId: 1,
    entryPointAddress:
      '0x1234567890123456789012345678901234567890'
  }
)
```

## Definition

```ts
function toTypedData(
  userOperation: UserOperation<'0.8' | '0.9', true>,
  options: toTypedData.Options,
): TypedData.Definition<typeof toTypedData.types, 'PackedUserOperation'>
```

**Source:** [src/erc4337/UserOperation.ts](https://github.com/wevm/ox/blob/main/src/erc4337/UserOperation.ts#L1098)

## Parameters

### userOperation

* **Type:** `UserOperation<'0.8' | '0.9', true>`

The user operation to convert.

#### userOperation.callData

* **Type:** `0x${string}`

The data to pass to the `sender` during the main execution call.

#### userOperation.callGasLimit

* **Type:** `bigintType`

The amount of gas to allocate the main execution call

#### userOperation.initCode

* **Type:** `0x${string}`
* **Optional**

Account init code. Only for new accounts.

#### userOperation.maxFeePerGas

* **Type:** `bigintType`

Maximum fee per gas.

#### userOperation.maxPriorityFeePerGas

* **Type:** `bigintType`

Maximum priority fee per gas.

#### userOperation.nonce

* **Type:** `bigintType`

Anti-replay parameter.

#### userOperation.paymasterAndData

* **Type:** `0x${string}`
* **Optional**

Paymaster address with calldata.

#### userOperation.preVerificationGas

* **Type:** `bigintType`

Extra gas to pay the Bundler.

#### userOperation.sender

* **Type:** `abitype_Address`

The account making the operation.

#### userOperation.signature

* **Type:** `0x${string}`

#### userOperation.verificationGasLimit

* **Type:** `bigintType`

The amount of gas to allocate for the verification step.

### options

* **Type:** `toTypedData.Options`

#### options.chainId

* **Type:** `number`

#### options.entryPointAddress

* **Type:** `abitype_Address`

## Return Type

A Typed Data definition.

`TypedData.Definition<typeof toTypedData.types, 'PackedUserOperation'>`
