So the real question is not how does barter generate some sort of medium of exchange, that then becomes money, but rather, how does that broad sense of ‘I owe you one’ turn into a precise system of measurement – that is: money as a unit of account?
By the time the curtain goes up on the historical record in ancient Mesopotamia, around 3200 BC, it’s already happened. There’s an elaborate system of money of account and complex credit systems. (Money as medium of exchange or as a standardized circulating units of gold, silver, bronze or whatever, only comes much later.)
So really, rather than the standard story – first there’s barter, then money, then finally credit comes out of that – if anything its precisely the other way around. Credit and debt comes first, then coinage emerges thousands of years later and then, when you do find “I’ll give you twenty chickens for that cow” type of barter systems, it’s usually when there used to be cash markets, but for some reason – as in Russia, for example, in 1998 – the currency collapses or disappears.