I am wondering how countries are able to force everyone to use its own currency, instead of some external currency (like the U.S. dollar or Bitcoin or cookies or something else not under government control). If businesses and citizens decide that they do not like the national currency (perhaps it is too turbulent or some other reason), and instead decide that they would like to "barter" a third-party currency for goods and services rather than "buying" those goods and services with the national currency, then the country would lose control of its own currency. This does happen at a small scale, where small businesses may accept a cryptocurrency instead of the local currency.
What different methods can a country employ to ensure that it does not lose control of its currency because its citizens switch to an unofficial alternate currency not controlled by the government?
If this situation does occur, how can a government still collect taxes on the exchange of this alternate money for goods and services? If I wanted to pay someone to mow my lawn in cookies instead of currency, the government could not tax this. If every business and citizen began treating cookies as the main form of payment, the government would lose all tax revenue. How can it stop this from happening?
If the answer involves creating a law that says "10% of all cookies (or bitcoins or something else) must be given to the government", then what prevents that currency from swiftly changing its name? Perhaps cookies become brownies, which do not fall under the law. Or bitcoins become a different cryptocurrency, or just change their name. This would become a game of cat-and-mouse between the laws and the currency. It seems like accepting alternate, nontaxable unofficial currencies, would become economically beneficial for both companies and individuals. Yet established governments in the world do not have this problem. How?