Nanoparticle formation by crosslinking a macromolecule