Money emerged out of the barter economy when goldsmiths kept gold for people and gave them receipts instead. The receipts became the "money".
In the 1600s, a lot of London merchants would place their gold in locked storage rooms of the goldsmiths in the city for preservation; the goldsmiths would give receipts to the merchants. The receipts could also be cashed in for gold, which had real value.