It is never explained in detail how the economy of the Federation works. In-universe, the New World Economy replaced capitalism, making money redundant – the UFP provides virtually everything. However, a currency called Federation Credits is mentioned several times and appears to be used for trade with non-Federation worlds.