We've all been there. The pain of sending 30 Ethereum to a online exchange, only to find that you don't want to exchange anymore and that it takes 50 Ethereum to withdraw.
Luckily, you're a cheapskate, so you tried to send it with a fee of 1 gwei instead. Therefore, it probably won't be confirmed until at least a day later. So what do you do?
If you're using metamask or something, that's easy. Just press cancel.
But what if you have cancel a transaction of, for example, bitcoin?
Then double spending comes into play.
What you have to do, is to send your money again, this time to yourself. However, you must make sure that the transaction fee is much higher than the previous one.
To maximize their profits, miners almost always choose the transaction with the higher fee to mine. Therefore, transactions with higher fees will almost always be validated quicker than transactions with lower fees.
If you make another transaction with higher fees, chances are that it will be validated quicker than the one with lower fees, and therefore the one with lower fees will be invalid before it is validated.
So, you have successfully canceled your transaction.
Thanks for reading.