  Magnetars are believed as neutron stars (NSs) with strong magnetic fields.
X-ray flares and fast radio bursts (FRBs) have been observed from the magnetar
(soft gamma-ray repeater, SGR J1935+2154). We propose that the phase transition
of the NS can power the FRBs and SGRs.Based on the equation of state provided
by the MIT bag model and the mean field approximation, we solve the
Tolman-Oppenheimer-Volkoff equations to get the NS structure. With spin-down of
the NS, the hadronic shell gradually transfers to the quark shell.The
gravitational potential energy released by one time of the phase transition can
be achieved. The released energy, time interval between two successive phase
transitions, and glitch are all consistent with the observations of the FRBs
and the X-ray flares from SGR J1935+2154. We conclude that the phase transition
of an NS is a plausible mechanism to power the SGRs as well as the repeating
FRBs.
