How to cancel or unblock transactions on BSC (or Ethereum)

in LifeStyle4 months ago

Unsplash

Sigh, I knew this day would happen for Binance Smart Chain eventually. The low gas fees wouldn't always stay low... and although they are still lower than those on Ethereum (especially with the recent crazy spike again...), it was only a matter of time when the number of people wanting to transact combined with the slow edging upwards of BNB price and the ability to make higher gas bids to prioritise transactions was going to make for slowly rising gas prices.

Seeing as Binance Smart Chain is basically very similar to Ethereum, I'm curious how Binance is going to try and curb this problem in the future. At the moment, it is still early days and Ethereum also had similarly low gas prices in the beginning. Ethereum is going with a 2.0 transition to Proof of Stake and L2 sidechains (OVM and OE being the two main solutions). Currently, Binance Smart Chain has a smaller validator set (less decentralisation means it is easier to process blocks faster and still stay in sync, although the last few hours has seen a significant number of reorgs).

Anyway, most of that... whilst interesting to nerds like me, is irrelevant for a regular user who just wants to buy the latest meme-coin! All they care about is the fact that their transaction is either stuck or they mashed the transaction button a few too times out of frustration and now have about a million queued swaps on Pancakeswap!

Well, here is a guide for unsticking and cancelling transactions that I had originally meant to publish a few days from now... but it appears that BSC got itself clogged a little earlier than planned! Anyway, this is a very similar method to that you would do on Ethereum. I had written a guide about it, but it hasn't gotten published yet... so, I will just do an adaptation for BSC.


Now, it is important to understand why your transaction is stuck in pending. Wallets will submit your transactions to a node to broadcast in order of nonce. The nonce is a single use number that is unique to each transaction and is sequential (goes up by one each time). If one transaction is stuck (you skimped on gas fees or the network average went above what you offered), then it won't be picked up for block inclusion.

You can wait it out and hope... but every transaction after it will have to wait until this one passes. Plus, if it is a swap or a smart contract interaction with a set time or slippage level, then you will likely see it fail when it finally executes. So, maybe you want to cancel it... to allow other transactions to execute or maybe you need to cancel multiple orders when you accidentally hammered the execute button a few too many times!

Screenshot 2021-05-11 09.47.38.png

First things first. Many mobile wallets don't offer an easy way to customise transaction nonces or to set custom fees. So, I would suggest setting up Metamask for BSC (you can follow the Binance Academy guide: here) and restoring your wallet on it with your seed key/phrase (which you HAVE backed up!).

Select your network. It will appear as Smart Chain if you did the set up properly (or select Ethereum mainnet if you want to do this for Ethereum).

Screenshot 2021-05-11 09.47.54.png

Go to the Metamask Settings.

Screenshot 2021-05-11 09.48.04.png

... and select the "Advanced" option. It's okay, you will only temporarily switch one toggle here and then return it back when you are done.

Screenshot 2021-05-11 09.48.23.png

Scroll down until you see the option to toggle the "Customise transaction nonce". Normally, a wallet will hide this from the user, as it can really screw things up if people start messing around with the transaction order without understanding what is going on. Toggle this to "ON".

Screenshot 2021-05-11 09.49.12.png

Now, head to BSCscan (or Etherscan if you want to do this on Ethereum) and find the transaction that you want to cancel. Click on the transaction hash of that transaction to be taken to the specific information page.

Screenshot 2021-05-11 09.49.53.png

Scroll down until you find the "Nonce" value (in this transaction it is 1043) and take note of the Gas Price that you had offerred as you will need to set a higher amount in order to cancel the transaction by front-running it.

Screenshot 2021-05-11 09.50.54.png

Now, we will front run the problem transaction with a simple token transfer to yourself with a higher gas fee. Higher gas fee plus a less complex transaction makes this much more attractive for miners to include in a block, and thus the transaction nonce will be used and the problem transaction will be rejected as it will have a duplicate nonce.

So, send yourself a small amount of BNB (or ETH if you are on Ethereum), and make sure that the transaction gas fee is higher than the problem transaction. You can always double check the going price for gas on BscScan (or EtherScan).

Don't mess with the gas limit, 21000 is more than adequate for a token transfer. Gas limit represents the maximum gas that will be used, whilst the gas price is the price per unit of gas.

Click Next.

Screenshot 2021-05-11 09.51.18.png

If you had toggled the "Custom Nonce" setting from earlier, this page will appear and you will be able to set your own nonce value. Set it to the number from the transaction that you want to cancel and send it onwards to a node (aka. click "Confirm").

The simple but higher gas price token transfer is now more likely to be picked up by the network than your problem transaction and will thus invalidate the old transaction as it will have a duplicate nonce. Problem solved!

Keep in mind that now that the block is cancelled, all subsequent orders will be in line to execute! So, be sure that that is okay... or set up cancellations for them FIRST!

Remember to go back and uncheck the Customise Nonce setting, it is always good to have that little trap hidden away again!

Handy Crypto Tools

Ledger Nano S/X: Keep your crypto safe and offline with the leading hardware wallet provider. Not your keys, not your crypto!
Binance: My first choice of centralised exchange, featuring a wide variety of crypto and savings products.
Kucoin: My second choice in exchanges, many tokens listed here that you can't get on Binance!
Coinbase: If you need a regulated and safe environment to trade, this is the first exchange for most newcomers!
Crypto.com: Mixed feelings, but they have the BEST looking VISA debit card in existence! Seriously, it is beautiful!
CoinList: Access to early investor and crowdsale of vetted and reserached projects.
Cointracking: Automated or manual tracking of crypto for accounting and taxation reports.

Ledger Nano S - The secure hardware wallet


Upgoats by ryivhnn
Account banner by jimramones


The classical music community (Subscribe at Steempeak and Peakd) at #classical-music and Discord. Follow our community accounts @classical-music and @classical-radio. Community Logo by ivan.atman