One definition of a "Nice Guy" is: someone who gives in order to guilt; they're nice and deferential and give to others, while pretending to not want anything in return, with the unconscious intention that others will later feel guilty and give them something. Sometimes a nice guy becomes resentful when they don't get what they want. They never asked for what they want, they never checked whether it was costing them to be so nice and giving, and the person they're being nice to never asked them to be nice nor agreed to the trade the nice guy imagines. An implicit social contract is an agreement that is unspoken but assumed to bind people's behavior, so that violations of those bounds are noticed and punished. The nice guy tries to take advantage of implicit social contracts: by pretending to not want anything in return, the nice guy prevents others from noticing that they are entering an implicit contract, and then later when they notice the contract they feel guilty and may give the nice guy something even though it costs them too much.
To avoid becoming resentful, to get what you want with people, and to avoid costing yourself unnecessarily:
Notice when you feel resentment. It is not bad. It might indicate that you made a mistake, so if you notice the resentment you can learn from the mistake. It might mean someone really should have done something for you, but they didn't, and so something is going wrong in them or in your relationship with them. Either way, the resentment points towards something that you wanted but didn't get, so now you can learn more about what you wanted, and know that it really is important to you, and learn about what doesn't work to get it.
Notice when you feel bound by implicit social contracts. It feels like "I'm supposed to do that thing for that person" or "It would be impolite to not X" or "I want to refuse their offered favor because I don't know what they expect in return" or "It's just what you do". That gives you a clue about what you think others think you owe to them in exchange for their behavior towards you. And what you think others think you owe them, is a clue about what you think others owe to you in exchange for your behavior towards them.
Give in order to get, but don't give in order to guilt. Notice if you're pretending that you don't want something in return, and ask yourself why you might want to be deceptive.
It makes sense to do things for others because you want something in return, and it makes sense to use implicit contracts; there's too many contracts to keep track of explicitly, and assuming that everyone is roughly on the same page is efficient, if not perfectly reliable. When things go wrong, you can use your mind to make updates, instead of making blunt force updates. To help have your mind available for updates, make your expectations explicit so that the other person can accept or refuse, or else notice that you think there's an implicit social contract, or else later when you feel resentment notice the resentment. Then, you can use your mind: you can update that you're exploitable in this particular way, rather than that you can never trust anyone ever. You can update that what you did for them was more costly than you realized and maybe you were ignoring that cost for some reason, rather than that you should never help anyone who hasn't already helped you. You can update that you were trying to guilt them because you didn't think what you had to offer was worth enough, rather than that you are fundamentally needy or fundamentally ungenerous. You can update that this person has a culture where reciprocity is more explicit and less implicit, rather than that they are fundamentally evil, uncaring, or exploitative.
Say you want to do something for someone but you're worried that something is fishy, like maybe they're exploiting you or maybe you're trying to guilt them, or maybe it's too costly, or maybe what you're going to do isn't actually so good for them. To get more information before costing yourself, confront the possible future situation where you've done the thing, and they did not notice or did not give you enough in return. Having gone through that, what would future-you have learned about the world? Is there anything that future-you would have wanted you to say or do differently?
It makes sense to do things for people. You might care about their wellbeing. There may be lots and lots of potential value to be gained from positive-sum trades. It makes sense to do things for people even if they've never done anything for you, and even if it's likely they won't directly give you something in return. Maybe they can help you a bit when you really need help. Maybe they'll pay it forward and make more abundance for the community you both live in.
Say that, on reflection, your resentment means that this person actually exploited you. To avoid being exploited more, update that they will, in general, as a matter of action, exploit people, whether or not they are aware. Say that you really communicated with them about the contract, and about what it's costing you, and they accepted the trade, but they still did the bad thing and they didn't have a good excuse. To avoid putting large amounts of your resources at stake by trusting them not to betray you, update that this person is trying to exploit you, and that they are evil and should not be trusted.