A drug dealer called police from a payphone and turned himself in, a court heard.
The officers arrived at Market Street in Batley and arrested Lee Hodgson.
He had seven wraps of crack cocaine and eight wraps of heroin on him, Kirklees magistrates were told.
Prosecutor Vanessa Jones told the Huddersfield court that on April 24 the 35-year-old phoned police to confess that he had been dealing drugs for three weeks.
She said he got himself into a situation he couldn’t get out of as he started dealing to pay off a debt he owed to another dealer.
Hodgson, of Smallwood Gardens in Dewsbury, gave no indication of plea to two charges of being concerned in the supply of a Class A drug.
Magistrates sent his case to Leeds Crown Court where he will appear for a plea and case management hearing on June 8.
He was told to comply with the Drug Intervention Team as part of his bail conditions after testing positive for the misuse of drugs following his arrest.