Michael Rennie was overheard moaning about his money worries in a pub – and that led to an offer to make some cash, the High Court in Edinburgh heard.
But undercover police had started a surveillance operation – and Rennie, 28, was caught with cocaine with a street value of more than £70,000.
In court, Rennie of Oxgangs Place, Edinburgh, admitted being concerned in the supply of the drug in June and July last year.
Jailing him, judge Lord Turnbull told Rennie he had been part of a sophisticated criminal enterprise to supply drugs which would damage individuals, families and society in general.
“You chose to become involved in that trade with your eyes open and must now take the consequences,” he said.