Rapper Tekashi 6ix9ine copped a secret plea deal — in which he admitted to hiring someone to shoot rival rapper Chief Keef and also to peddling a kilo of heroin — and is now cooperating with the feds, newly unsealed court documents reveal.

The rainbow-haired rapper took the plea deal Jan. 23 for his involvement with a violent street crew called the “Nine Trey Gangsta Bloods,” but the agreement was sealed so that prosecutors would have enough time to charge and arrest more of the gang members, according to a transcript of last week’s proceeding in Manhattan federal court.

TEKASHI 6IX9INE MAY BE CUTTING A DEAL WITH FEDERAL INVESTIGATORS FROM PRISON

Tekashi said during the plea that he joined the gang in 2017.

“On or about June 2, 2018, in furtherance of Nine Trey, of the Nine Trey enterprise, I paid a person to shoot at a rival member of Nine Trey to scare him. The shooting took place in Manhattan,” he told a judge.

“I did this to maintain or increase my own standing in Nine Trey. In furtherance of this shooting, I knew that a member of Nine Trey discharged a gun,” Tekashi added.

RAPPER TEKASHI 6IX9INE ESCAPES JAIL TIME IN CHILD SEX CASE: REPORT

He also admitted that, “On or about March 20, 2018, I helped members of Nine Trey attempt to kill a rival gang member.”

Tekashi said he took part in an April gunpoint robbery and that in 2017 sold a kilo of heroin.

The 22-year-old hip-hop artist pleaded guilty to nine federal felonies including racketeering conspiracy, firearms charges, narcotics trafficking, and violent crimes in aid of racketeering.

TEKASHI 6IX9INE TRANSFERRED FROM FEDERAL JAIL FOR 'SECURITY REASON': REPORT

Yesterday, a new indictment charged three more men in the case, including for the Chief Keef shooting in Midtown in June.

This article originally appeared in Page Six.