The invention relates to a method for treating sludge produced by a slaughtering wastewater treatment plant by using chrysomyia megacephala maggots and a material formula. According to the method, adjuvants are added to the sludge and are stirred so as to prepare a chrysomyia megacephala maggot feeding material, chrysomyia megacephala eggs are put into the chrysomyia megacephala maggot feeding material, and larvae incubated from the chrysomyia megacephala eggs eat the chrysomyia megacephala maggot feeding material, so that the sludge is treated. The mass fraction of the sludge in the chrysomyia megacephala maggot feeding material is 45-95%, the rest is the adjuvants, and the adjuvants consist of the following substances in percentage by weight: 0-30% of cattle manure, 0-40% of bagasse, 0-10% of rapeseed meal, 0-40% of peanut shell, 0-30% of corncob, 0-30% of beer dregs, 0-30% of bran powder, 0-5% of potassium dihydrogen phosphate and 0-5% of sodium dihydrogen phosphate. The method and the material formula have the advantages that the treating capacity is strong, the treating speed is higher than that of ordinary composting, and the treatment cycle is 4-5 days. After treatment, the volume of the sludge is decreased by 10-30%, odors are reduced, and meanwhile, a high-quality organic fertilizer and high-quality insect biological protein can be obtained.