In Rumpelstiltskin, a miller's careless boast that his clever daughter can spin gold from straw is forced by the king to deliver on this claim. A little man arrives to help the miller's distraught daughter in exchange for her firstborn child. Later, when the daughter, now the queen, gives birth to her first child, the little man comes to collect. He agrees to release the queen from her promise if she can learn his name.
According to researchers at Durham University and the Universidade Nova de Lisboa, this story originated around 4,000 years ago.