• Packs a UserOperation into an EIP-712 compatible format for signing or verification.

    Parameters

    • userOp: {
          callData: `0x${string}`;
          callGasLimit: bigint;
          initCode: `0x${string}`;
          maxFeePerGas: bigint;
          maxPriorityFeePerGas: bigint;
          nonce: bigint;
          paymasterAndData: `0x${string}`;
          preVerificationGas: bigint;
          sender: `0x${string}`;
          signature: `0x${string}`;
          verificationGasLimit: bigint;
      }

      The user operation to pack

      • callData: `0x${string}`
      • callGasLimit: bigint

        Gas limit for the main execution call

      • initCode: `0x${string}`
      • maxFeePerGas: bigint

        Maximum total fee per gas unit

      • maxPriorityFeePerGas: bigint

        Maximum priority fee per gas unit

      • nonce: bigint

        Account nonce

      • paymasterAndData: `0x${string}`
      • preVerificationGas: bigint

        Gas overhead for pre-verification operations

      • sender: `0x${string}`
      • signature: `0x${string}`
      • verificationGasLimit: bigint

        Gas limit for the verification phase

    • forSignature: boolean = true

      If true, returns the packed data for signing (excludes the signature field)

    Returns string

    The packed user operation as a hex string

    // Pack for signing
    const packedForSign = packUserOpV6(userOp, true);

    // Pack with signature included
    const packedWithSig = packUserOpV6(userOp, false);