Shay Alexander Harper, 22, was observed by police in a car parked outside the Shrewsbury home of a person believed to be the victim of county lines 'cuckooing' drug dealers.
In drug dealing terms, cuckooing is how dealers from outside the county establish bases in small towns by taking over the homes of vulnerable people, often addicts.
Harper was accompanied in the car by three other men, all four of them from Cheshire. Two of them are due to face more serious drugs charges soon.
Speaking at Shrewsbury Crown Court, solicitor Ms Samantha Powis said: "These offences came to light on January 22, 2019, when, in the afternoon, two officers from the county lines team saw a blue Corsa parked outside the address of someone they believed to be a cuckooing victim."
The Vauxhall Corsa drove off with the four men inside, the court heard. Officers followed the car and pulled it over in the Castle Foregate area of the town.
When he was searched by police, Harper was found to have 146mg of heroin, two bags of cannabis and a cannabis grinder on his person.
He admitted he had stayed at the address and had bought drugs from a local dealer.
Harper, of Dee Fords Avenue, in Chester, pleaded guilty to two charges of possessing drugs, of class A and class B.
Representing Harper in court, Miss Debra White said he was of good character prior to the offences last year and has found stable employment since.
Recorder James Smith, who heard the case, told Harper: "The other individuals in the car were found to have significant amounts of drugs around their person.
"You were found to have a limited amount. To a certain extent this should be a warning shot to you, how close you have come to...being prosecuted for far more serious charges which could have lead to custodial sentences."
He characterised him as "a relatively young man who has gone on to get a job and is proceeding positively".
He handed down a £500 fine for the heroin possession, with no separate penalty for the cannabis.
Two of the other men in the car that day are due to be sentenced next month for more serious offences.
Peter Gilmartin, 22, of Elm Square in Chester, faces charges of conspiracy to supply class A and class B drugs, and two charges of possessing class A drugs.
Meanwhile Jack Marsland, 21, of Blacon Avenue, Blacon, Chester, faces identical conspiracy charges as well as one of possession of criminal property.
The case against the fourth man in the car has been dropped.