The invention belongs to the technical field of oil exploitation, and particularly relates to a
foaming agent for
nitrogen foam well cementation and a preparation method thereof. The preparation method comprises the following steps: adding
tris (
hydroxymethyl) aminomethane,
ethanol and dodecyl
halide into a reactor, uniformly stirring, heating, carrying out a heat preservation reaction, and adjusting the pH value; adding benzyl
halide into the reactor, uniformly stirring, heating, preserving heat and reacting, and adjusting the pH value; carrying out reduced pressure
distillation to obtain a
viscous liquid, adding
toluene for dissolving, transferring into a high-pressure reaction kettle, adding a catalyst, closing the reaction kettle, stirring, heating, vacuumizing, introducing
ethylene oxide, heating after the introduction is completed, stopping heating when the pressure does not drop any more, and cooling the
system; adjusting the pH value, adding
sulfamic acid powder, heating while stirring, carrying out heat preservation reaction, and cooling; and filtering and carrying out reduced pressure
distillation to obtain a viscous
solid, namely the
foaming agent product for well cementation. The
foaming agent for well cementation has the advantages of large foaming volume and long half-life period.