Context. Mantles of iced water mixed with carbon monoxyde, formaldehyde, and methanol are formed during the so-called prestellar core phase. In addition, radicals are also thought to be formed on the grain surfaces, and to react to form complex organic molecules later on, during the so-called warm-up phase of the protostellar evolution. Aims. We aim to study the formation of the grain mantles during the prestellar core phase and the abundance of formaldehyde, methanol, and radicals trapped in them. Methods. We have developed a macrosopic statistic multilayer model that follows the formation of grain mantles with time and that includes two effects that may increase the number of radicals trapped in the mantles: i) during the mantle formation, only the surface layer is chemically active and not the entire bulk; and ii) the porous structure of grains allows the trapping reactive particles. The model considers a network of H, O, and CO forming neutral species such as water, CO, formaldehyde, and methanol, plus several radicals. We ran a large grid of models to study the impact of the mantle multilayer nature and grain porous structure. In addition, we explored how the uncertainty of other key parameters influences the mantle composition. Results. Our model predicts relatively high abundances of radicals, especially of HCO and CH 3 O (10 −9 −10 −7 ). In addition, the multilayer approach enables us to follow the chemical differentiation within the grain mantle, showing that the mantles are far from being uniform. For example, methanol is mostly present in the outer layers of the mantles, whereas CO and other reactive species are trapped in the inner layers. The overall mantle composition depends on the density and age of the prestellar core as well as on some microscopic parameters, such as the diffusion energy and the hydrogenation reactions activation energy. Comparison with observations allows us to constrain the value of the last two parameters (0.5-0.65 and 1500 K, respectively) and provide some indications on the physical conditions during the formation of the ices.