Skip to content

UserOperation.fromRpc

Converts an UserOperation.Rpc to an UserOperation.UserOperation.

Imports

Named
import { UserOperation } from 'ox/erc4337'

Examples

import { UserOperation } from 'ox/erc4337'
 
const userOperation = UserOperation.fromRpc({
  callData: '0xdeadbeef',
  callGasLimit: '0x69420',
  maxFeePerGas: '0x2ca6ae494',
  maxPriorityFeePerGas: '0x41cc3c0',
  nonce: '0x357',
  preVerificationGas: '0x69420',
  signature: '0x',
  sender: '0x1234567890123456789012345678901234567890',
  verificationGasLimit: '0x69420',
})

Definition

function fromRpc(
  rpc: Rpc,
): UserOperation

Source: src/erc4337/UserOperation.ts

Parameters

rpc

  • Type: Rpc

The RPC user operation to convert.

rpc.callData

  • Type: 0x${string}

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

rpc.callGasLimit

  • Type: bigintType

The amount of gas to allocate the main execution call

rpc.initCode

  • Type: 0x${string}
  • Optional

Account init code. Only for new accounts.

rpc.maxFeePerGas

  • Type: bigintType

Maximum fee per gas.

rpc.maxPriorityFeePerGas

  • Type: bigintType

Maximum priority fee per gas.

rpc.nonce

  • Type: bigintType

Anti-replay parameter.

rpc.paymasterAndData

  • Type: 0x${string}
  • Optional

Paymaster address with calldata.

rpc.preVerificationGas

  • Type: bigintType

Extra gas to pay the Bundler.

rpc.sender

  • Type: abitype_Address

The account making the operation.

rpc.signature

  • Type: 0x${string}

rpc.verificationGasLimit

  • Type: bigintType

The amount of gas to allocate for the verification step.

Return Type

An instantiated UserOperation.UserOperation.

UserOperation.UserOperation