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

primitives/UserOperation

Type Aliases

UserOperationType

UserOperationType = object & object
Defined in: src/primitives/UserOperation/UserOperationType.ts:16 UserOperation type - ERC-4337 v0.6 format User operations enable account abstraction by separating transaction validation from execution. Bundlers aggregate user operations and submit them to the EntryPoint contract for execution.

Type Declaration

callData
readonly callData: Uint8Array
Calldata to execute on the account
callGasLimit
readonly callGasLimit: Type
Gas limit for the execution phase
initCode
readonly initCode: Uint8Array
Account factory and initialization code for first-time deployment
maxFeePerGas
readonly maxFeePerGas: Type
Maximum total fee per gas (EIP-1559)
maxPriorityFeePerGas
readonly maxPriorityFeePerGas: Type
Maximum priority fee per gas (EIP-1559)
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
verificationGasLimit
readonly verificationGasLimit: Type
Gas limit for the verification phase

Type Declaration

[brand]
readonly [brand]: "UserOperation"

See

Since

0.0.0

Variables

UserOperation

const UserOperation: object
Defined in: src/primitives/UserOperation/index.ts:32

Type Declaration

from()
from: (params) => UserOperationType
Create UserOperation from input object
Parameters
params
UserOperation parameters
callData
string | Uint8Array<ArrayBufferLike> Calldata to execute
callGasLimit
string | number | bigint | Type Gas for execution
initCode
string | Uint8Array<ArrayBufferLike> Account initialization code
maxFeePerGas
string | number | bigint | Type Max total fee per gas
maxPriorityFeePerGas
string | number | bigint | Type Max priority fee per gas
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
verificationGasLimit
string | number | bigint | Type Gas for verification
Returns
UserOperationType UserOperation
Example
const userOp = UserOperation.from({
  sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3",
  nonce: 0n,
  initCode: "0x",
  callData: "0x",
  callGasLimit: 100000n,
  verificationGasLimit: 200000n,
  preVerificationGas: 50000n,
  maxFeePerGas: 1000000000n,
  maxPriorityFeePerGas: 1000000000n,
  paymasterAndData: "0x",
  signature: "0x",
});
hash()
hash: (userOp, entryPoint, chainId) => Uint8Array
Parameters
userOp
UserOperationType
entryPoint
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType
chainId
number | bigint
Returns
Uint8Array
pack()
pack: (userOp) => PackedUserOperationType
Parameters
userOp
UserOperationType
Returns
PackedUserOperationType

Functions

_hash()

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

Parameters

userOp
UserOperationType 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 = UserOperation.hash(userOp, ENTRYPOINT_V06, 1n);
const signature = await account.signMessage(hash);

_pack()

_pack(userOp): PackedUserOperationType
Defined in: src/primitives/UserOperation/pack.js:14 Pack UserOperation (v0.6) to PackedUserOperation (v0.7) Packs gas limits and fees into bytes32 for v0.7 entry point.

Parameters

userOp
UserOperationType User operation v0.6

Returns

PackedUserOperationType Packed user operation v0.7

Example

const packedUserOp = UserOperation.pack(userOp);

from()

from(params): UserOperationType
Defined in: src/primitives/UserOperation/from.js:38 Create UserOperation from input object

Parameters

params
UserOperation parameters
callData
string | Uint8Array<ArrayBufferLike> Calldata to execute
callGasLimit
string | number | bigint | Type Gas for execution
initCode
string | Uint8Array<ArrayBufferLike> Account initialization code
maxFeePerGas
string | number | bigint | Type Max total fee per gas
maxPriorityFeePerGas
string | number | bigint | Type Max priority fee per gas
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
verificationGasLimit
string | number | bigint | Type Gas for verification

Returns

UserOperationType UserOperation

Example

const userOp = UserOperation.from({
  sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3",
  nonce: 0n,
  initCode: "0x",
  callData: "0x",
  callGasLimit: 100000n,
  verificationGasLimit: 200000n,
  preVerificationGas: 50000n,
  maxFeePerGas: 1000000000n,
  maxPriorityFeePerGas: 1000000000n,
  paymasterAndData: "0x",
  signature: "0x",
});

hash()

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

Parameters

userOp
UserOperationType
entryPoint
string | number | bigint | Uint8Array<ArrayBufferLike> | AddressType
chainId
number | bigint

Returns

Uint8Array

pack()

pack(userOp): PackedUserOperationType
Defined in: src/primitives/UserOperation/index.ts:24

Parameters

userOp
UserOperationType

Returns

PackedUserOperationType