Gavin Scoular,19, used BlackBerry Messenger, Skype, Facebook and Snapchat to get in touch with the children, who were aged between 10 and 12, on various occasions between August 2012 to August 2013.
Edinburgh Sheriff Court heard how Scoular sent messages asking his victims to perform sex acts on him.
The court heard how he told one 12-year-old girl he would post indecent images of her online if she did not comply with his request. On another occasion, the girl and her friend were forced to watch Scoular performing a sex act on himself on Skype. He even met a 13-year-old girl in a field near Edinburgh's Royal Infirmary Hospital and sexually assaulted her.
Scoular, of Oxgangs Terrace, Edinburgh, pleaded guilty last month to a series of charges under the Sexual Offences Scotland Act 2009.
Yesterday Sheriff Alistair Noble ordered Scoular to be detained in custody for 18 months.
He also ordered him to be supervised by the authorities for three years after his release. Scoular's name was also put on the Sex Offenders Register for 10 years.