Reliable control of p- and n-type conductivity in perovskite semiconductors, enabling high-performance optoelectronic devices.