The taarof is an essential part of Iranian culture. For the beginner's eyes, it could be explained as an extreme politeness behaviour. But it’s more complex than that and it requires lots of practice and experience to master the Iranian taarof!
The first thing you'll notice, wherever you travel to Iran, is the usage of this word: "Befarma". It could be translated into English by "please". Depending on the context, it also means "you go first", "help yourself", and other polite invitations to take a sit, enjoy a meal, or anything else. But it goes way beyond saying "you go first" while holding the door.
Following the taarof, it would be rude just to say thank you and pass through the door without returning the same "befarma". Iranians will rather refuse, saying "no it's impossible, you first", and so on... It can truly continue like this between the counterparts for endless minutes until someone decides to enter! This "door situation" is so common that it's subject to many jokes and parodies among Iranians, who refers to it funnily as "the door of hell".
Of course, as a foreigner, people don't expect you to follow the taarof’s rules and will never be offended that you went out of the elevator first, or unscrupulously accepted this cookie without a second thought. This false step won't be a great deal either. But it sometimes goes so far that people will gladly offer you their own food, drive you somewhere, pay your ticket entrance, or even offer you this nice item they have that you just complimented. In those situations, it's better to have your "taarof" alarm on, to avoid mistakenly taking advantage of your host's generosity.
Thus, the first unwritten "rule" is to refuse everything three times, to make sure it's not taarof. Good luck refusing beyond the second time though...! In some situations, you might have no other options than being a helpless witness. At the restaurant, for instance, you can be sure that everybody will literally fight to pay for the bill. Actually, even the waiter will never give it without saying something like: "It’s worthless, for you/You don't owe me anything" (Ghâbel nadâre).
It's a really common saying from sellers, drivers, and any merchants to say that you're their guests and you don't have to pay. What is normally expected from you is simply to thanks them, and of course, pay for your charges. Even if you have to insist, or remind it later to your Iranian's friend who paid the restaurant's bill... If your host was not doing taarof and paying your share appears offending, then offering a small gift is always a nice way to express your gratitude.
The more you'll travel to Iran, the more familiar you'll get with the taarof. You'll soon notice that it manifests itself in everyday life. While answering their phone, Iranian usually greet the other person on the line with a litany of taarofing sayings. Entering a taxi or leaving a restaurant, one can also greet the workers by wishing them: "don't be tired" (Khaste nabashid). And there is plenty of other common sayings to say things in a nicer way.
All this might be a bit confusing for tourists and foreigners. It's true that it's not always easy to figure out who's "doing taarof" or not. Even so, taarof is never about hypocrisy or lying. On the contrary, it expresses respect and mutual gratitude. Taarof is a strong and endearing social tenet, which tells a lot about Iran and its people. And it somehow makes all these daily transactions and exchanges way sweeter!
To summarize let's watch a fun video about Taarof.