Earth is a post-scarcity society, and this idea has been expanded throughout the Federation. However other species still use money, so resources have to be bartered with others.
Now, while it is noted in ENT and TOS that Starfleet officers earn their pay, I don’t think it is meant to be taken literally.
VOY (episode "Dark Frontier") mentioned something about the New World Economy taking hold in the late 22nd century and money becoming nonexistent. However, Sisko mentioned in "Past Tense" that the world that Starfleet recognized was at least a century away, i.e. 2113, even though the Bell Riots of 2024 were the beginning of change towards that world, WW3 and post atomic horror aside. And there isn’t a world government until 2150, a year before the NX-01 launches, which will have its own impact on the economy.
The absence of greed seems to be the main philosophy behind the origins of a moneyless society. Which is something humans and Ferengi will disagree on.