In any felony proceeding or in any investigation or proceeding before a grand jury for any felony offense if a person refuses to answer a question or produce evidence of any other kind on the ground that he or she may be incriminated thereby, and if the district attorney of the county or any other prosecuting agency in writing requests the court, in and for that county, to order that person to answer the question or produce the evidence, a judge shall set a time for hearing and order the person to appear before the court and show cause, if any, why the question should not be answered or the evidence produced, and the court shall order the question answered or the evidence produced unless it finds that to do so would be clearly contrary to the public interest, or could subject the witness to a criminal prosecution in another jurisdiction, and that person shall comply with the order. After complying, and if, but for this section, he or she would have been privileged to withhold the answer given or the evidence produced by him or her, no testimony or other information compelled under the order or any information directly or indirectly derived from the testimony or other information may be used against the witness in any criminal case. But he or she may nevertheless be prosecuted or subjected to penalty or forfeiture for any perjury, false swearing or contempt committed in answering, or failing to answer, or in producing, or failing to produce, evidence in accordance with the order. Nothing in this section shall prohibit the district attorney or any other prosecuting agency from requesting an order granting use immunity or transactional immunity to a witness compelled to give testimony or produce evidence.
Ca. Pen. Code § 1324