A landworker tried to swim away from a police officer after he was caught selling cocaine in Boston town centre.
Jake Halliday, 28, came to the attention of officers after he was spotted jumping over rail barriers which were in the down position.
Lincoln Crown Court heard the officers were initially concerned for his safety but then noticed a drugs exchange taking place with another man.
Halliday tried to ride off on his bike when he was approached by a police officer and then jumped into the River Witham in an attempt to swim away.
The officer saw a foil wrap and chocolate egg packaging used to hide the cocaine wrap float away, the court was told.
When the officer told Halliday he was "being stupid," he replied: "Ok, I'm coming out."
Once he was the out the water Halliday added: "It's the first time I've done it, it was just a little bit of coke, I did it for my mate."
Halliday, of no fixed address, admitted being concerned in the supply of cocaine on July 19 this year.
Sunil Khanna, mitigating, said Halliday was a hardworking landworker who was unfortunately out of work because of the extreme hot weather in July.
Mr Khanna told the court: "He had not been able to work for two weeks because of health and safety rules. It was simply too hot.
"Mr Halliday had run out of money and was offered £5 to give a single wrap to another man and collect £20.
"There is no indication he had done it before, and he won't do it again. He didn't appreciate how serious it is."
Passing sentence Recorder James House QC told Halliday street dealing was a serious matter.
"I'm not going to send you to prison today," Recorder House said. "But only by the skin of your teeth.
"Being involved in the supply of Class A drugs is very serious."
Halliday was given a 12 month community order and must complete 250 hours of unpaid work.