AbstractFrom a rational convex polytope of dimension r⩾2 J.P. Hansen constructed an error correcting code of length n=(q−1)r over the finite field Fq. A rational convex polytope is the same datum as a normal toric variety and a Cartier divisor. The code is obtained evaluating rational functions of the toric variety defined by the polytope at the algebraic torus, and it is an evaluation code in the sense of Goppa. We compute the dimension of the code using cohomology. The minimum distance is estimated using intersection theory and mixed volumes, extending the methods of J.P. Hansen for plane polytopes. Finally we give counterexamples to Joyner's conjectures [D. Joyner, Toric codes over finite fields, Appl. Algebra Engrg. Comm. Comput. 15 (20...