Bernard Hayes helpfully guided British Transport Police officers towards the tennis ball-sized wrap of the class A drug when he was stopped at Doncaster Railway Station in March.
The 51-year-old was travelling between Bradford and Grimsby when he was stopped in the station and found to be carrying a knife.
Sheffield Crown Court heard how, when asked if he was carrying drugs, he replied: "Yes, in my jacket pocket."
The wrap, later confirmed to be 107g of individual wraps of heroin, was found inside the pocket of Hayes' puffer jacket as he was searched under the Section 23 of the Misuse of Drugs Act, and he was immediately arrested.
Hayes, of Braybrook Court, Bradford, pleaded guilty at Doncaster Magistrates' Court to one count of possession with intent to supply a drug of Class A status and one count of possession of a bladed article over the incident on the evening of March 16.
A judge at Sheffield Crown Court last week sentenced him to three years and one month.
BTP Detective Inspector, Matt Davies, said: “It’s evident from what was found in Hayes’ possession on that day that he was using the railway network to transport large quantities of drugs.
“I am thankful to the courts for the sentence handed down to him – he’ll now have plenty of time behind bars to reconsider his criminality.
“Our plain-clothed and uniformed County Lines Taskforce officers are patrolling the railway day in, day out to tackle the movement of drugs and illicit cash between locations."
Hayes will serve 32 months for possession with intent to supply a drug of Class A status and five months for possession of a bladed article. He is also required to pay a victim surcharge of £190.