The problem with your proposal is that countries don't actually trade with each other. Businesses do.
For example, a palm oil farmer posts an advert on the Internet and a soap company in South Africa chooses to buy the palm oil for manufacturing. Of course they trade in dollars, because that's the currency they both know about. The Nigerian farmer can immediately convert his dollars to naira to spend at home, or use it to import farm equipment!
So the government is hardly involved in import/export and that's a
good thing. Barter won't work, because it requires double coincidence of wants. A farmer that wants to exchange her palm oil for tractors, would need to find a soap factory that also manufactures tractors, way of determining the number of gallons of palm oil that should be exchanged for one tractor. This complicated process is eliminated by using a trusted common currency - the dollar!