Kodak Black is going to prison.

Black, 22, was sentenced on Wednesday to 46 months in prison on federal weapons charges, as confirmed by Bradenton. The maximum sentence that he could have been slapped with is 10 years.

Following a short stint in Niagara County Jail after being arrested at the U.S.-Canada border and charged with drugs and weapon possession last month, the rapper was arrested again at Miami’s Rolling Loud music festival on May 11.

Black was charged with falsifying information on multiple federal documents, allegedly so he could buy firearms from a local gun shop in both January and March.

According to Bruce Brown, an assistant U.S. attorney, Black purchased a nine-millimetre handgun, a .380-calibre handgun and a semi-automatic Mini Draco weapon.

The 21-year-old musician pleaded not guilty on May 15. Although he was previously granted release on a US$550,000 bond and handed a house arrest sentence, Judge Federico Moreno of the U.S. District Court overturned that decision on Wednesday, as reported by the Associated Press.

Moreno claimed that given his extensive criminal record, Black, whose legal name is Bill Kapri, was a “danger to the community.” The judge also expressed concern with the musician’s history of possessing firearms.

It was determined that the Zeze rapper will remain detained until trial.

READ MORE: Kodak Black arrested at U.S.-Canada border for gun, drug possession

Local authorities said one of the weapons allegedly bought by Black was found at the scene of a shooting that took place in March in Pompano Beach, Fla.

Kodak Black attends the <em>Dying To Live</em> album listening party at Harlem Parish on Dec. 12, 2018 in New York City.
Kodak Black attends the <em>Dying To Live</em> album listening party at Harlem Parish on Dec. 12, 2018 in New York City. — Johnny Nunez/WireImage

“I’m very concerned with the type of guns he wanted to get a hold of and that he has a prior (criminal record),” Moreno told the Miami Herald.

“He was out on bond and committed an offence,” the judge added, referring to the arrest of Black in late 2016 and his alleged violation of a long-standing probation. “I think he’s a danger to the community because he wants to have access to guns.”

In November 2016, Black was detained and indicted on charges of sexual assault after he was accused of sexually abusing a woman in South Carolina. He was released on a $100,000 bond in December 2016, according to Pitchfork.

READ MORE: Ellen DeGeneres claims she was sexually abused by her stepfather

In defence of Black, attorney Bradford Cohen claimed that the rapper required firearms because he supposedly faced violent threats from gang members and other individuals. They were “legitimate threats made” against Black, according to Cohen.

WATCH: Rapper Kodak Black released from Niagara County jail, uses wads of cash to cover face

View link »

As a result of his detainment, Black was forced to cancel a large number of concert dates and has cancelled the remainder of his Dying to Live tour, including all shows on its Canadian leg.

Black could potentially be sentenced up to eight years in prison if convicted in the upcoming trial.

With files from ET Canada and the Associated Press