• Validates a user operation against the appropriate schema based on its version. Uses Zod schemas to ensure all required fields are present and have the correct types.

    Parameters

    Returns UserOperation

    The validated user operation with correct types

    Error if validation fails or if the operation format is invalid

    // Validate a v0.6.0 operation
    const validatedV6 = validateUserOperation({
    sender: "0x123...",
    nonce: 1n,
    paymasterAndData: "0x456...",
    // ... other v0.6.0 fields
    });

    // Validate a v0.7.0 operation
    const validatedV7 = validateUserOperation({
    sender: "0x123...",
    nonce: 1n,
    paymaster: "0x456...",
    // ... other v0.7.0 fields
    });