Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/PackedUserOperation

primitives/PackedUserOperation

Type Aliases

PackedUserOperationType

PackedUserOperationType = object & object
Defined in: src/primitives/PackedUserOperation/PackedUserOperationType.ts:19 PackedUserOperation type - ERC-4337 v0.7+ format Optimized format that packs gas limits and fees into bytes32 fields, reducing calldata size and gas costs for bundlers. Gas packing format:
  • accountGasLimits: verificationGasLimit (128 bits) || callGasLimit (128 bits)
  • gasFees: maxPriorityFeePerGas (128 bits) || maxFeePerGas (128 bits)

Type Declaration

accountGasLimits
readonly accountGasLimits: Uint8Array
Packed gas limits: verificationGasLimit (128) || callGasLimit (128)
callData
readonly callData: Uint8Array
Calldata to execute on the account
gasFees
readonly gasFees: Uint8Array
Packed fees: maxPriorityFeePerGas (128) || maxFeePerGas (128)
initCode
readonly initCode: Uint8Array
Account factory and initialization code for first-time deployment
nonce
readonly nonce: Type
Anti-replay nonce (key + sequence)
paymasterAndData
readonly paymasterAndData: Uint8Array
Paymaster address and data (empty if self-paying)
preVerificationGas
readonly preVerificationGas: Type
Fixed gas overhead for bundler compensation
sender
readonly sender: AddressType
Smart account address initiating the operation
signature
readonly signature: Uint8Array
Account signature over userOpHash

Type Declaration

[brand]
readonly [brand]: "PackedUserOperation"

See

Since

0.0.0

Variables

PackedUserOperation

const PackedUserOperation: object
Defined in: src/primitives/PackedUserOperation/index.ts:34

Type Declaration

from()
from: (params) => PackedUserOperationType
Create PackedUserOperation from input object
Parameters
params
PackedUserOperation parameters
accountGasLimits
string | Uint8Array<ArrayBufferLike> Packed gas limits (32 bytes)
callData
string | Uint8Array<ArrayBufferLike> Calldata to execute
gasFees
string | Uint8Array<ArrayBufferLike> Packed gas fees (32 bytes)
initCode
string | Uint8Array<ArrayBufferLike> Account initialization code
nonce
string | number | bigint | Type Anti-replay nonce
paymasterAndData
string | Uint8Array<ArrayBufferLike> Paymaster address and data
preVerificationGas
string | number | bigint | Type Fixed gas overhead
sender
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType Smart account address
signature
string | Uint8Array<ArrayBufferLike> Account signature
Returns
PackedUserOperationType PackedUserOperation
Example
const packedUserOp = PackedUserOperation.from({
  sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3",
  nonce: 0n,
  initCode: "0x",
  callData: "0x",
  accountGasLimits: "0x...", // 32 bytes
  preVerificationGas: 50000n,
  gasFees: "0x...", // 32 bytes
  paymasterAndData: "0x",
  signature: "0x",
});
hash()
hash: (packedUserOp, entryPoint, chainId) => Uint8Array
Parameters
packedUserOp
PackedUserOperationType
entryPoint
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType
chainId
number | bigint
Returns
Uint8Array
unpack()
unpack: (packedUserOp) => UserOperationType
Parameters
packedUserOp
PackedUserOperationType
Returns
UserOperationType

Functions

_hash()

_hash(packedUserOp, entryPoint, chainId): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/PackedUserOperation/hash.js:21 Compute userOpHash for PackedUserOperation userOpHash = keccak256(abi.encode(packedUserOp, entryPoint, chainId))

Parameters

packedUserOp
PackedUserOperationType Packed user operation
entryPoint
EntryPoint contract address string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType
chainId
Chain ID number | bigint

Returns

Uint8Array<ArrayBufferLike> 32-byte hash for signing

Example

const hash = PackedUserOperation.hash(packedUserOp, ENTRYPOINT_V07, 1n);
const signature = await account.signMessage(hash);

_unpack()

_unpack(packedUserOp): UserOperationType
Defined in: src/primitives/PackedUserOperation/unpack.js:16 Unpack PackedUserOperation (v0.7) to UserOperation (v0.6) Extracts gas limits and fees from packed bytes32 fields.

Parameters

packedUserOp
PackedUserOperationType Packed user operation v0.7

Returns

UserOperationType User operation v0.6

Example

const userOp = PackedUserOperation.unpack(packedUserOp);

from()

from(params): PackedUserOperationType
Defined in: src/primitives/PackedUserOperation/from.js:34 Create PackedUserOperation from input object

Parameters

params
PackedUserOperation parameters
accountGasLimits
string | Uint8Array<ArrayBufferLike> Packed gas limits (32 bytes)
callData
string | Uint8Array<ArrayBufferLike> Calldata to execute
gasFees
string | Uint8Array<ArrayBufferLike> Packed gas fees (32 bytes)
initCode
string | Uint8Array<ArrayBufferLike> Account initialization code
nonce
string | number | bigint | Type Anti-replay nonce
paymasterAndData
string | Uint8Array<ArrayBufferLike> Paymaster address and data
preVerificationGas
string | number | bigint | Type Fixed gas overhead
sender
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType Smart account address
signature
string | Uint8Array<ArrayBufferLike> Account signature

Returns

PackedUserOperationType PackedUserOperation

Example

const packedUserOp = PackedUserOperation.from({
  sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3",
  nonce: 0n,
  initCode: "0x",
  callData: "0x",
  accountGasLimits: "0x...", // 32 bytes
  preVerificationGas: 50000n,
  gasFees: "0x...", // 32 bytes
  paymasterAndData: "0x",
  signature: "0x",
});

hash()

hash(packedUserOp, entryPoint, chainId): Uint8Array
Defined in: src/primitives/PackedUserOperation/index.ts:16

Parameters

packedUserOp
PackedUserOperationType
entryPoint
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType
chainId
number | bigint

Returns

Uint8Array

unpack()

unpack(packedUserOp): UserOperationType
Defined in: src/primitives/PackedUserOperation/index.ts:24

Parameters

packedUserOp
PackedUserOperationType

Returns

UserOperationType