Recent observational data cast serious doubt on the widely held view that the sun's corona is heated by traveling waves (acoustic or magnetohydrodynamic). It is here proposed that the energy responsible for heating the corona is derived from the free energy of the coronal magnetic field derived from motion of the 'feet' of magnetic field lines in the photosphere. Stochastic motion of the feet of magnetic field lines leads, on the average, to a linear increase of magnetic free energy with time. This rate of energy input is calculated for a simple model of a single thin flux tube. The model appears to agree well with observational data if the magnetic flux originates in small regions of high magnetic field strength as proposed by Tarbell et al. (1979). On combining this energy input with estimates of energy loss by radiation and of energy redistribution by thermal conduction, scaling laws are obtained for density and temperature in terms of length and coronal magnetic field strength.