In this work we show that algebraic lattices constructed from error-correcting codes achieve the ergodic capacity of the fading channel. The main ingredients for our construction are a generalized version of the Minkowski-Hlawka theorem and shaping techniques based on the lattice Gaussian distribution. The structure of the ring of integers in a number field plays an important role in the proposed construction. In the case of independent and identically distributed fadings, the lattices considered exhibit full diversity and an exponential decay of the probability of error with respect to the blocklength.