The court heard that police had received information that Martin Blain, 34, of 24 Bayview Road had been concerned in supplying the drug for some time.
They executed a search warrant on the home of the father-of-two, which he shares with his partner and sometimes his children, on November 26. They found a bag of brown powder in his bedside drawer which tested as the heroin, and £600 in cash.
The court heard that Blain served a previous sentence for similar offences in 1999.
Sheriff Kenneth Robb told Blain: “Even knowing you had a previous conviction, you still got yourself involved in the supply of drugs again.”
Blain was sent to jail with his sentence backdated to November 26.