Nicky McKenzie, 37, a prisoner at Perth, was jailed for three years by Sheriff Alastair Brown.
McKenzie admitted that on June 1, in Dundee’s Murraygate and at police HQ, Bell Street, he was concerned in the supply of heroin.
Depute fiscal John Adams said McKenzie had been stopped by police in the street as he appeared to be unsteady on his feet.
He was detained and searched, and a Kinder Egg containing three wraps was found in a pocket of his jeans.
He was taken to Bell Street and a further search revealed a further 14 wraps.
The heroin recovered was valued at between £200 and £330, the fiscal said.