Metal ion adsorption and electrocrystallization