Police recovered £300 worth of heroin after they searched a Galashiels man who had fallen asleep.
Officers were called to Queen Elizabeth Square last month after witnesses saw Rory Morrison staggering around outside his home with his top off.
Procurator fiscal Graham Fraser said: “He was intoxicated by drugs and unable to speak. He appeared disorientated and had a small white tub in the pocket of his jogging bottoms. He said it was smack.
“At that point witnesses called the police. When they arrived, the accused had fallen asleep.
“They searched him while he was seemingly unconscious and the drugs were found in his possession.”
Mr Fraser said the heroin weighed around 10 grammes.
Sheriff Peter Paterson noted Morrison had only just been released from prison when he committed the offence, after being on remand on a charge he was subsequently cleared of.
He said: “I am going to give you a chance, but if you mess up you know where you will be going.”
Morrison, 31, was placed on a high-tariff deferred sentence until September 24.