  We present a constrained transport (CT) algorithm for solving the 3D ideal
magnetohydrodynamic (MHD) equations on a moving mesh, which maintains the
divergence-free condition on the magnetic field to machine-precision. Our CT
scheme uses an unstructured representation of the magnetic vector potential,
making the numerical method simple and computationally efficient. The scheme is
implemented in the moving mesh code Arepo. We demonstrate the performance of
the approach with simulations of driven MHD turbulence, a magnetized disc
galaxy, and a cosmological volume with primordial magnetic field. We compare
the outcomes of these experiments to those obtained with a previously
implemented Powell divergence-cleaning scheme. While CT and the Powell
technique yield similar results in idealized test problems, some differences
are seen in situations more representative of astrophysical flows. In the
turbulence simulations, the Powell cleaning scheme artificially grows the mean
magnetic field, while CT maintains this conserved quantity of ideal MHD. In the
disc simulation, CT gives slower magnetic field growth rate and saturates to
equipartition between the turbulent kinetic energy and magnetic energy, whereas
Powell cleaning produces a dynamically dominant magnetic field. Such difference
has been observed in adaptive-mesh refinement codes with CT and
smoothed-particle hydrodynamics codes with divergence-cleaning. In the
cosmological simulation, both approaches give similar magnetic amplification,
but Powell exhibits more cell-level noise. CT methods in general are more
accurate than divergence-cleaning techniques, and, when coupled to a moving
mesh can exploit the advantages of automatic spatial/temporal adaptivity and
reduced advection errors, allowing for improved astrophysical MHD simulations.
