How to cancel a pending transaction
- Author
- CRYPTO PORT Editorial
- Published
- Updated
- Reading time
- 5 min
In short
An unconfirmed transaction can often be nullified by sending an empty transaction to yourself at the same nonce with a higher fee. Most wallets provide a function for this. Success is not guaranteed, a transaction that has already confirmed can never be cancelled, and the cancellation itself costs a fee.
Key points
- It exploits the rule that only one transaction per nonce can confirm
- It cannot touch a confirmed transaction — there is no undo there
- The cancelling transaction carries its own fee
- Whether it works depends on network conditions; there is no guarantee
Definition
Replacing a submitted but unconfirmed transaction with a different transaction at the same nonce, so the original never executes.
Cancellation works because of how nonces behave. Transactions from one account are numbered in order, and only one transaction per number can ever confirm. So if you submit a different transaction at the same number as your unconfirmed one and get it confirmed first, the original has nowhere to go. That is what cancelling really is: overwriting, not undoing.
The replacement is normally a trivial transaction sending zero to yourself. It does nothing except consume the nonce. Its fee has to be higher than the original's — leave it low and the original confirms first and nothing is cancelled. Most wallets show an item meaning cancel when you open a pending transaction and assemble this for you, with names and placement varying by app.
The situations where it helps are narrow. The common one is withdrawing a transaction that has sat pending for a long time because its fee was set too low. The other is realising a mistake immediately after sending, but that is a race: blocks come quickly and it is not unusual to find the transaction already confirmed by the time you notice. In that case there is nothing to be done.
Be clear that it can fail. If the original gets picked up before your cancellation does, nothing is cancelled and the cancellation fee is spent anyway. The more congested the network, the less predictable this contest becomes. You therefore cannot operate on the assumption that you can cancel later — checking before you sign is the only reliable defence.
Note also that undoing an approval granted to a dApp is a different matter entirely. An approval that has already confirmed can only be neutralised by revoking it; see 'How to revoke a token approval'.
Watch out for
- · Confirmed transactions cannot be cancelled; this is strictly a pending-state tool
- · A failed cancellation still costs its fee, and the original may confirm regardless
- · Anyone claiming they can cancel transactions for you or roll one back is running a scam
Frequently asked questions
If I cancel, do I get the funds back?
Because the original never executes, the funds simply stay in your wallet — though the fee spent on the cancelling transaction is gone. If the original had already confirmed, the funds are with the recipient and do not come back.