Once a transaction has been mined and is included into a block in the blockchain, it cannot be canceled or replaced. Normally, with the right gas price and limit settings, Polygon transactions are mined within a few seconds and do not spend much time in the transaction pool.
However, with the very high gas price these days, transactions could be pending for hours or days. Pending/dropped transactions are getting more common now and knowing how to replace these transactions becomes a required and useful skill.
Before we dive deeper, it is important to note that you can only do this if your transaction is still pending. If it's already through, the transaction cannot be replaced or cancelled anymore.
Replacing a Pending Transaction
To replace a Polygon transaction, first, make sure that the transaction is still pending. Check its transaction hash on Polygonscan to see its latest status. If the transaction is still pending, look for the pending transaction’s nonce on the Transaction Details page. Refer below:
Some wallet interfaces provide you with options to set a higher gas fee than their default suggestion and change a transaction’s nonce.
Let’s use the MetaMask wallet platform as an example.
Access your MetaMask extension, click on the round icon at the top right corner and click on Settings. Now, enable the Customize transaction nonce and Advance gas controls options.
Go back to your pending transaction’s Transaction Details page on Polygonscan. Make sure the status is still at Pending and take note of its nonce number. You are going to need it in the coming steps.
Now, re-do the pending transaction (create a new transaction with exactly the same details as the pending on) BUT, change and set a higher gas price and change the nonce of this new transaction to the same nonce as the pending transaction. Not changing the nonce will create another transaction that is bound to be stuck at the same Pending status and not replacing the existing pending transaction as intended. If unsure on the best gas price for the replacement transaction, you can refer to Polygonscan's Gas Tracker page for the recommended new Gas Price. Afterward, click Confirm to proceed.
Once the new transaction has been successfully created, you will now see two pending transactions on your MetaMask wallet. From here, you can check the status of your new transaction on Polygonscan.
If all goes well, your original transaction should be replaced once the new transaction has been confirmed.