The purpose of this presentation is to analyze the transformation and the social background of a group of folktales in which a foreigner visits a city or village to find and buy an unknown treasure. This type of folktale became widespread in China from the fourth and fifth centuries to the twentieth century. In this paper, I will interpret the hidden meaning and the historical background of the folktale. The folktale had a mythological and cosmological structure and functioned as on intermediary between the gods and human beings. However, the folktale began to secularize and the meaning of the story changed after the ninth and tenth centuries in accordance with international and domestic social changes. I will analyze the process and factors of the change in function and structure of the folktale.