# UserOperation.toRpc

Converts a [`UserOperation.UserOperation`](/ercs/erc4337/UserOperation/types#useroperation) to a [`UserOperation.Rpc`](/ercs/erc4337/UserOperation/types#rpc).

## 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 userOperation = UserOperation.toRpc({
  callData: '0xdeadbeef',
  callGasLimit: 300_000n,
  maxFeePerGas: Value.fromGwei('20'),
  maxPriorityFeePerGas: Value.fromGwei('2'),
  nonce: 69n,
  preVerificationGas: 100_000n,
  sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
  verificationGasLimit: 100_000n
})
```

## Definition

```ts
function toRpc<entryPointVersion>(
  userOperation: toRpc.Input<entryPointVersion>,
): Rpc<entryPointVersion>
```

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

## Parameters

### userOperation

* **Type:** `toRpc.Input<entryPointVersion>`

The user operation to convert.

## Return Type

An RPC-formatted user operation.

`Rpc<entryPointVersion>`
