A man took off his hat to reveal to police officers that he was carrying cocaine with a street value of more than £400, a court has heard.
Joshua Day, 22, of Oakes Road, Bury St Edmunds, was arrested on December 28 after his car was stopped by police who noticed a strong smell of cannabis inside.
Yesterday Ipswich Crown Court heard that Day had tested positive for cocaine.
Prosecuting, Russell Butcher said when Day removed his cap he revealed he was carrying a wrap of cocaine.
When his home was searched, officers discovered notes about drug dealing and Day said his mobile phone was likely to contain text messages which were drug related.
Day pleaded guilty to being concerned in making an offer to supply unlawful drugs and possession of cocaine. He was sentenced to two years imprisonment, suspended for two years and ordered to complete 200 hours unpaid work.