This is the double-spending problem, and finding a solution to this is what ultimately makes cryptocurrencies work.