All the other posts here have good explanations of why the dollar is so widely used for trade. However it’s worth pointing out a flaw in your premise: the US dollar isn’t the “official currency for any import or export”.
There are quite a lot of commodities – particularly oil – that are traded almost entirely in dollars, and I think that gives people a misleading impression. Actually the dollar doesn’t even seem to be used for the *majority* of international trade, let alone all of it.
For example, last year, 40% of international payments via the SWIFT system were in dollars. That was only just ahead of euro payments. Back in the early 2010s, there were actually more payments in euros. Looking at invoicing the figures are similar, looking at actual payments the USD is under 10%, with over 50% in “other” currencies. (Although there are big problems with the data quality for the latter two, eg. there’s very little data for China(!).)
The reason for why the euro is used so much is pretty obvious when you think about it. Imagine I live in German and I want to sell to France. Or I live in Northern France and my nearest supermarket is in Belgium. Am I going to use dollars? Obviously not, I’ll use euros.
The EU is the largest cluster of rich countries in the world and they’re the most integrated economies in the world, so there’s a *lot* of trade between EU countries. So you might consider the statistics to be a little misleading (you might see this trade as closer to trade between US states, for example). However even outside of the EU there’s lots of trade being conducted in currencies other than the dollar.
(For anyone interested, [here’s](https://www.imf.org/en/Publications/WP/Issues/2023/03/24/Currency-Usage-for-Cross-Border-Payments-531324) a source on currency usage, drawing on SWIFT data and [here’s](https://www.imf.org/en/Publications/WP/Issues/2020/07/17/Patterns-in-Invoicing-Currency-in-Global-Trade-49574) one on invoicing.)
Latest Answers