Cancel or Replace a blockchain transaction
In some cases, you may want to cancel or replace a transaction.
- Cancel: for EVM chains (like Ethereum), it may be possible to replace a pending transaction in the mempool via another one with value zero (0) to your own address. UTXO transactions can't be "canceled".
- Replace: for UTXO chains (like Bitcoin), it may be possible to increase the fee of a pending transaction via RBF (if enabled) or via CPFP. For EVM chains, it may be possible to replace a pending transaction.
Confirmed blockchain transactions cannot be canceled or reverted. Once a transaction has been confirmed and added into a block, it's final.
Cancelling a transaction
EVM chains allow a bit of a trick to cancel a pending (unconfirmed) transaction in the mempool:
- Verify the transaction you want to cancel is not confirmed yet and is still pending in the mempool. Check an Explorer.
- Verify the nonce value of the unconfirmed transaction you want to cancel.
- Create a new transaction where the sender and receiver blockchain address is the same with a zero (0) amount. Use the same nonce value you got from step 2 and put a much higher fee.
- Broadcast this transaction. Ideally, the miners will prioritize this new transaction over the original due to a higher fee.
- If all worked well, your new transaction will get confirmed first and the original will be dropped due to invalid.
Replacing a transaction
UTXO chains may allow RBF or in some cases CPFP on pending (unconfirmed) transactions.
EVM chains may allow replacing a transaction using the same method as if you were to cancel it:
- Verify the transaction you want to cancel is not confirmed yet and is still pending in the mempool. Check an Explorer.
- Verify the nonce value of the unconfirmed transaction you want to replace.
- Create a new transaction where the receiver blockchain address may or may not be the same as in the original to replace. Use the same nonce value you got from step 2 and put a much higher fee.
- Broadcast this transaction. Ideally, the miners will prioritize this new transaction over the original due to a higher fee.
- If all works well, your new transaction will get confirmed first and the original will be dropped due to invalid.
Good to know
- Incorrectly executed transactions may result in the loss of funds.
- For pending or unconfirmed transactions, there's no guarantee of success in canceling or replacing them.
- Blockchain transactions, once confirmed, are final (irreversible).
Updated 5 months ago