Alexander Purves, 33, was stopped after police received a tip-off that the driver of a silver Volkswagen Bora was returning from Shotts to Edinburgh in possession of controlled drugs.
The High Court in Edinburgh heard when Purves was stopped and his car searched two 1/2 kilo packages of heroin were found in a fabric bag below the passenger seat.
At an earlier hearing advocate depute Morag Jack said the wholesale value of the drugs would be 15,000 but could realise 100,000 based on a kilo being broken down into 10,000 "tenner" bag deals.
Purves, of Newcraighall Drive, admitted being concerned in the supplying of the Class A drug at Hermiston Gait, Edinburgh, the A720 Edinburgh City Bypass, Straiton Road, Loanhead, Midlothian and elsewhere on 11 August 2009.
Ms Jack told the court the police investigation pointed to Purves' involvement in the operation as one of a courier.
She said when he was interviewed he denied any knowledge of the two heroin packages.
Ms Jack said: "Further he denied having being given this fabric bag by someone in Shotts before retuning.
"He indicated that he occasionally used cannabis but had never used heroin.
"Further he stated that he was in considerable debt."
The court heard Purves was on sick leave from his job as a car valet.
Defence solicitor advocate Duncan Hughes said Purves had not served a custodial sentence before and had four previous convictions at summary level.
He said: "He is at the bottom end of the chain of supply."
Mr Hughes added that Purves was having financial difficulties having split with his girlfriend and he was being paid to courier the drugs.
Judge Lord Uist told Purves: "The chain of the supply of heroin could not operate if there were not people such as you willing to act as couriers.
"Those who become concerned in the supplying of heroin must know that there is a risk of a prison sentence when brought to justice."
The judge added Purves' sentence would have been four years if he had been convicted after trial.