Cobalt nanoparticles have been synthesized via a novel, foam-based protocol. The foam is formed from an aqueous mixture of Co2+ ions, an anionic surfactant and oleic acid where the cobalt ions are electrostatically entrapped by the surfactant at the thin borders between the foam bubbles and their junctions. The entrapped cobalt ions may be reduced in-situ by a moderately strong reducing agent resulting in the formation of nanoparticles with the foam playing the role of a template. The nanoparticles are immediately capped and stabilized against oxidation by oleic acid present in the foam matrix. The oleic acid-capped Co nanoparticles can be redispersed either in an aqueous or organic medium making this procedure very attractive. The cobalt nanoparticles are readily converted to CocoreAgshell nanoparticles by simple addition of a silver salt to the Co nanoparticle solution, the cobalt atoms on the nanoparticle surface acting as localized reducing agents for the silver ions.