In a large bowl, combine the flour and salt. Create a well in the center and add the beaten egg, warm water, and melted butter. Mix to form a dough.
Knead the dough on a floured surface until it becomes smooth and elastic. Cover it and let it rest for about 20 minutes.
Meanwhile, prepare the filling by sautéing the diced onion in butter until translucent, and then mix it with the mashed potatoes and shredded cheese.
Roll out the dough on a floured surface to 1/8-inch thickness. Cut out circles using a 3-inch cookie cutter or glass.
Place a tablespoon of filling in the center of each circle, fold over, and seal edges by pinching. You may use a fork to crimp edges.
Bring a large pot of salted water to a boil. Drop pierogi in batches and cook until they float to the surface, about 3-5 minutes.
Optional: Fry boiled pierogi in a pan with butter until golden brown on both sides.