Electrochemically controlled deposition of nanomaterials