EntryPoint utilities

A collection of utility assets relevant to version 0.6 of the EntryPoint contract.

The EntryPoint namespace provides a collection of useful, types, functions, and constants which are relevant to v0.6 and can be reused throughout your application.

Types

These are common ERC-4337 types which are used extensively in userop.js.

UserOperation

The base User Operation type used within userop.js.

import { V06 } from "userop"

const userop: V06.EntryPoint.UserOperation = {
  // See interface below...
};

interface UserOperation {
  sender: Address;
  nonce: bigint;
  initCode: Hex;
  callData: Hex;
  callGasLimit: bigint;
  verificationGasLimit: bigint;
  preVerificationGas: bigint;
  maxFeePerGas: bigint;
  maxPriorityFeePerGas: bigint;
  paymasterAndData: Hex;
  signature: Hex;
}

RawUserOperation

A User Operation type that contains only contains 0x hex strings. Userop.js will transform a User Operation to this type before sending it to a Bundler.

import { V06 } from "userop"

const userop: V06.EntryPoint.RawUserOperation = {
  // See interface below...
};

interface RawUserOperation {
  sender: Address;
  nonce: Hex;
  initCode: Hex;
  callData: Hex;
  callGasLimit: Hex;
  verificationGasLimit: Hex;
  preVerificationGas: Hex;
  maxFeePerGas: Hex;
  maxPriorityFeePerGas: Hex;
  paymasterAndData: Hex;
  signature: Hex;
}

Utility functions

These are common utility functions which are used extensively in userop.js.

calculateUserOpHash

Takes a User Operation, EntryPoint address, and chain ID number to generate a userOpHash. This is a globally unique hash string and typically used as part of a message for a private key to sign when generating a User Operation signature.

import { V06 } from "userop";

const userOpHash = V06.EntryPoint.calculateUserOpHash(
  userOp,
  entryPointAddress,
  chainId,
);

toRawUserOperation

A simple helper function to transform a UserOperation type to a RawUserOperation type.

import { V06 } from "userop";

const rawUserOp = V06.EntryPoint.toRawUserOperation(userOp);

Constants

These are common constant values which are used extensively in userop.js.

CONTRACT_ABI

The ABI for v0.6 of the canonical EntryPoint contract.

import { V06 } from "userop";

const abi = V06.EntryPoint.CONTRACT_ABI;

DEFAULT_ADDRESS

The default address of the v0.6 canonical EntryPoint contract.

import { V06 } from "userop";

const abi = V06.EntryPoint.DEFAULT_ADDRESS; // "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

DEFAULT_USEROP

The initial template used to build a new User Operation.

import { V06 } from "userop";

const userop = V06.EntryPoint.DEFAULT_USEROP;

/*
userop will be assigned the following object:

{
  sender: zeroAddress,
  nonce: 0n,
  initCode: "0x",
  callData: "0x",
  callGasLimit: 0n,
  verificationGasLimit: 0n,
  preVerificationGas: 0n,
  maxFeePerGas: 0n,
  maxPriorityFeePerGas: 0n,
  paymasterAndData: "0x",
  signature: "0x",
};
*/