Allan McCormick was caught sending pictures and videos of his “micro-penis” to who he believed to be three young schoolgirls.
McCormick, 52, also sent videos to the girls of him urinating into a toilet bowl and of him performing a solo sex act.
But the married father-of-two was snared by police after it emerged he had been in contact with adult decoys from three vigilante gangs which were based in Edinburgh.
Edinburgh crime: City OAP who went missing has been murdered, police say
Edinburgh bin strike: Here's what to do with your waste while workers are on strike
Edinburgh crime news: Man arrested after Princes Street incident as man, named as Wayne Elliot, has died in hospital
Ex-Fettes College teacher Peter Coshan's disappearance treated as murder
Edinburgh crime: Man who assaulted friend of 15 years as she slept on sofa placed on Sex Offenders Register
Members of Groom Resistors Scotland, Decoy Scotland and Justice For The Innocent groups then arranged to meet McCormick in a sting operation in Glasgow city centre.
Edinburgh Sheriff Court was told the meeting was recorded and live-streamed on the three groups’ Facebook pages to thousands of viewers.
McCormick pleaded guilty to three offences of sending sexual comments and images to who he believed were children between July and September 2018 when he appeared at Edinburgh Sheriff Court on Friday.
Prosecutor Ross Price told the court a decoy belonging to Groom Resistors Scotland set up an online account on the Waplog dating app in the name of 12-year-old Maddie from Aberdeen.
The fiscal said McCormick, from Newlands, Glasgow, made contact with the account and soon began sending indecent messages claiming he was a virgin.
The chats soon moved to WhatsApp where the sicko asked the youngster to send him images of her breasts and genitals.
McCormick also told ‘Maddie’: “Please email me - you will laugh at me with me my tiny little thing.
“I woke up yesterday morning and my penis had totally shrunk to under 1.5 inches and is still the same today.
“It’s the size of a 12-year-old boys.”
McCormick also send ‘Maddie’ messages encouraging her to masturbate.
The court was told McCormick then made contact with ‘13-year-old Connie’ who was an adult decoy from the Decoy Central organisation.
He sent the account numerous images of his penis and videos of him performing solo sex acts as well as a recording of him urinating in to a toilet.
McCormick also made contact with a third adult decoy from Justice for the Innocent believing them to be a 12-year-old child named Chelsea.
The court was told he sent several photos of his “flaccid and erect penis” along with videos of him masturbating.
McCormick was subsequently lured to a meeting with the groups in Glasgow after a decoy pretended to be a 22-year-old woman who was interested in dating him.
But when he turned up to the September 2018 meet the group live streamed the sting to their Facebook followers and contacted the police.
Solicitor Sinead Corrigan, defending, told the court her client suffered from heart problems and had attended hospital on several occasion over the past year.
The lawyer said she would reserve all her mitigation to the sentencing hearing.
Sheriff Daniel Kelly said: “I am going to adjourn the case for a social work report. That means you will have to see a social worker and discuss matters with them.
“Up to now you have been on bail but you have now pleaded guilty to three serious charges and there is a risk of further offending so you will be remanded in custody.”
The sheriff placed McCormick on the Sex Offenders Register and deferred full sentence to later this month.