The man who arguably founded modern economic theory, the 18th-century Scottish philosopher Adam Smith, popularized the idea that barter was a precursor to money. In The Wealth of Nations, he describes an imaginary scenario in which a baker living before the invention of money wanted a butcher’s meat but had nothing the butcher wanted.“No exchange can, in this case, be made between them,” Smith wrote.
When two people each have items the other wants, both people can determine the values of the items and provide the amount that results in an optimal allocation of resources. Therefore, if an individual has 20 pounds of rice that he values at $10, he can exchange it with another individual who needs rice and who has something that the individual wants that's valued at $10. A person can also exchange an item for something that the individual does not need because there is a ready market to dispose of that item.