A teenager had €400 worth of cocaine in a schoolbag when gardai stopped a car in which he was travelling, a court heard.
Landscaper Andrew Lynch (19) was told he can avoid a criminal record if he donates two weeks' wages - €600 - to charity.
Lynch, of Pace Avenue, Clonee, pleaded guilty to poss- ession of cocaine with intent to sell or supply. He also admitted a related charge of simple possession.
The incident happened at Damastown Road, Mulhuddart, last December 29.
Sgt Maria Callaghan told Blanchardstown District Court that gardai on patrol at 3.40am stopped a car and got a strong smell of cannabis when it was opened and they spoke to the occupants.
They searched the vehicle and a schoolbag was discovered on the back seat.
This contained cannabis with a street value of €400, said Sgt Callaghan.
Lynch took responsibility for the drugs and was cooperative when interviewed.
He had no previous convictions of any kind.
"He regrets his foolish decision to get involved in this enterprise," said defence solicitor Matthew Kenny.
To his credit, he had no previous convictions and has not come to the attention of the gardai since.
The court heard Lynch was currently working as a landscaper.
Mr Kenny asked Judge John Lindsay to consider adjourning the case to give his client time to pay compensation to avoid a conviction.
He said a lot of "doors would be closed to him for ever" if he were convicted.
Sgt Callaghan said the gardai had no difficulty with this.
Judge Lindsay adjourned the case to a date next month and said he would strike the charge out if the charity donation to MS Ireland is paid.
The defendant, who did not address the court during the hearing, was remanded on continuing bail.