Fabrication and functionalization of nanomaterials