Armie Hammer learned a very specific skill while filming “Sorry to Bother You.”

He plays a corrupt CEO in Boots Riley’s absurdist dark comedy, a role that required him to snort a long line of cocaine. Of course, the on-screen substance wasn’t real, but a little moviemaking magic meant he didn’t actually have to inhale the white powder that his character snorts through a rolled-up Benjamin.

“It was like B12, but they had a hose that went down my shirt, into my hand,” Hammer told Dakota Johnson during Variety’s Actors on Actors. “Then I had the wrapped-up $100 bill with the hose that went into that, so I didn’t even have to snort anything.”

Not all actors are as lucky. In fact, he said, Jonah Hill had to snort so much fake cocaine on the set of 2013’s “The Wolf of Wall Street” that Hill ended up in the hospital.

Hammer, who received critical acclaim for his performance in the coming-of-age drama “Call Me by Your Name,” was ready to play a gonzo character like the one in “Sorry to Bother You.”

“I loved the idea of playing a crazy character. Nobody ever asked me to play crazy characters,” he says. “This was the first time someone brought a fascinating, bizarre character. I get to be this guy who comes in and just acts like f–king lunatic. And I loved that idea.”

Hammer recalled that when Riley approached him for the role, the director told him he didn’t want anyone else for the part.

“I later found out he asked 75 people to do it and they all said no, but thank God they said no because I got to do it,” he laughed.