The sources of the energy required for the formation of magma oceans in the early Solar System were the radioactive decay of aluminium-26, accretionary impacts, and core formation. The abundance and short half life of aluminium-26 allowed it to function as one of the sources of heat for the melting of planetesimals. With aluminium-26 as a heat source, planetesimals that had accreted within 2 Ma after the formation of the first solids in the Solar System could melt. Melting in the planetesimals began in the interior and the interior magma ocean transported heat via convection. Planetesimals larger than 20 km in radius that accreted within 2 Ma are expected to have melted, although not completely.
The kinetic energy provided by accretionary impacts and the loss of potential energy from a planet during core formation are also large heat sources for planet melting. Core formation, also referred to as metal-silicate differentiation, is the separation of metallic components from silicate in the magma that sink to form a planetary core. Accretionary impacts that produce heat for the melting of planet embryos and large terrestrial planets have an estimated timescale of tens to hundreds of millions of years.  A prime example would be the Moon-forming impact on Earth, that is thought to have formed a magma ocean with a depth of up to 2000 km. The energy of accretionary impacts foremost melt the exterior of the planetary body, and the potential energy provided by core differentiation and the sinking of metals melts the interior.