We study the initial-boundary value problem for the derivative nonlinear Schrödinger (DNLS) equation. More precisely we study the wellposedness theory and the regularity properties of the DNLS equation on the half line. We prove almost sharp local wellposedness, nonlinear smoothing, and small data global wellposedness in the energy space. One of the obstructions is that the crucial gauge transformation we use replaces the boundary condition with a nonlocal one. We resolve this issue by running an additional fixed point argument. Our method also implies almost sharp local and small energy global wellposedness, and an improved smoothing estimate for the quintic Schrödinger equation on the half line. In the last part of the paper we consider the DNLS equation on R and prove smoothing estimates by combining the restricted norm method with a normal form transformation.