Ghulam Rasool Ahmad, 32, was on licence from a previous jail term for trafficking when he became involved in a major supplying operation.
Lord Emslie ordered Ahmad, of Carmichael Place, to serve the remaining 15 months of his earlier sentence and added eight years and four months for the new offence.
The judge said: "This is the kind of offence this court has to take a serious view of… a class A drug, over a period of months in those quantities and values, and it came so soon after your release from a High Court sentence."
Ahmad had been convicted at a trial last month of being concerned in the supplying of heroin between August and December 2008 at a flat in Kingsburgh Crescent, Granton, of which he was a tenant.
Sentence had been deferred until yesterday for background reports, and the court heard that Ahmad had served less than half of a three-year sentence for a similar offence before being freed in March 2008.
"He struggled on his release and found employment difficult to come by because of his time in custody and an addiction to drugs. His is a desperately familiar pattern of minor offending and then developing an addiction which brought about his conviction in 2007," said defence counsel David Nicholson.
Reports described Ahmad as "somewhat lacking in nous", and Mr Nicholson said that, whatever the accused's role in the new offence, he was unlikely to have been the brains behind it.