Christopher Hill, 17, caused 4000 worth of damage when he started the blaze at Turniedykes Farm, Pathhead, on August 31 last year.
Fiscal depute Dev Kapadia told Edinburgh Sheriff Court a group of youths were climbing on the hay bales at the farm when Hill decided to light the plastic wrapping with a view to playing with the hay inside.
Mr Kapadia said: "The accused was seen by a number of witnesses to have a cigarette lighter and the plastic wrapping on the hay was lit with the lighter and unfortunately the fire took hold of the wrapping and spread to the bail of hay it was attached to. The fire then spread quickly amongst the other bails. All the other witnesses and the accused tried in vain to put the fire out but soon realised the scale was too much for them and they all ran away from the locus. One of the witnesses made his way home and informed his mother of what had happened and the police were contacted."
First offender Hill, of Dewartown, Gorebridge, admitted culpably and recklessly setting fire to the hay bales causing the fire to take effect and destroy the bales.
Defence agent Mark Hutchison said: "He was one of a number of children all playing in a park who went over to play with these hay bales. He had just turned 16 and a suggestion was made by one of the group to burn the plastic to gain access to the hay to play with it. This was a piece of stupidity of the part of Hill and his friends - they had not thought through the effect of burning the plastic on the hay."
Mr Hutchison added that Hill was still at school and was not usually a person who got in trouble.
Sheriff Alistair Noble said he would defer sentence on Hill for him to prove he can behave.