brice.btc

Dec 226 min read

Help! My Transaction is Stuck

Due to a bunch of new users, and a very full mempool, I’ve recently been trying to help lots of new Stacks users deal with transactions that are not getting included in blocks. To make it easier, I figured it would be easier to just write up the common issues in one place that I can link them to, so here it is, my one stop shop for debugging stuck transactions. Ping me on Twitter/X at @obycode or in the Stacks Discord at brice.btc with any comments, questions, or suggestions for improvements to this guide.

Check Your Nonce

In Stacks (and many other networks) transactions include a “nonce”. This is just a simple counter that is used to ensure that transactions are executed in order and cannot be replayed after they have been executed. Sometimes, wallet software might choose the wrong nonce for your transaction. If the nonce of your transaction is not the next number for your account, then the miners will never pick it up. To check your nonce, view your transaction in Hiro’s Explorer by clicking on the transaction in your wallet. For example, in the Leather wallet, go to the Activity tab and click on the transaction:

This will take you to the Explorer page for your transaction, which looks like this:

Notice the “Nonce” on this page (115 in the example above). Remember this number, then click on your address, the “Sender address” on the transaction page. This will take you to the Explorer page for your address.

On this page, you’ll see the “Last executed tx nonce” (113 in this example). This is important. If the nonce that showed on your transaction page is not your last executed nonce + 1, then either there is another pending transaction before this one, or you are missing a nonce. You can click on the “Pending” tab on this page to see other transactions that are pending in your account.

Missing Nonces

If from the above investigation, you discover that you are missing one or more nonces, then you’ll need to fill these nonces with other transactions. If you don’t have any other real transactions to do, you can always just send a tiny amount of STX (0.000001) from one account to another (note that you can’t transfer STX from an account to the same account). To create these transactions to fill in missing nonces, you’re going to need to modify the nonce suggested by your wallet to make sure it selects the right number. In this example above, we need to fill in nonce 114. In the Leather Wallet, I can click “Send”, then select “Stacks”, set the amount to 0.000001 STX and use the dropdown to select another one of my own accounts as the recipient.

Don’t click that Continue button yet. First we need to scroll down and click the “Edit nonce” button

There, you can set the value to the next nonce, as determined in the first section, then continue and sign your transaction. Do this with as many nonces as you need to fill the gap!

Ensure your Transaction is Mineable

Once you’ve confirmed that the nonce is correct, you should check to be sure that your transaction is mineable. If it’s not, then it will be forever ignored by the miners. Examples of transactions that might be un-mineable could be a contract deploy with a name that has already been used for that account, or a transaction with a fee that is higher than the balance in the account. In the second case, even if you later add STX to the account so that the balance is now high enough, the transaction will have already been added to an ignore list by the miner and you’ll need to resubmit it to get it picked up.

Increase the Fee

If you’ve confirmed that you don’t have any missing nonces, and you’re confident that your transaction is mineable, then the next problem could be that your fee is not high enough to be included in a block. The specific amount needed to get into a block can vary wildly depending on how expensive of a transaction you have, and how much traffic is currently in the mempool. If the mempool is relatively empty, you can get an expensive contract deploy included for less than 0.01 STX, but when the network is really busy, you may see people paying 30 STX for a simple transfer!

In the Leather wallet, when you hover over a pending transaction, you’ll see the option to increase the fee:

Click that, then adjust your fee to whatever amount seems appropriate in the current conditions (and that you are willing to pay). After this new transaction with a higher fee has been broadcast, you will see that the original transaction has been dropped.

Replace a Pending Transaction

If you have a pending transaction that you no longer want to be included in a block, you can’t exactly cancel it, but you can replace it with a different transaction. While it’s not a guarantee that the original transaction won’t be included in a block (a miner may have built the block before it saw your new transaction), it is very likely that the new transaction will take its place.

When you create a new transaction, manually update the fee to ensure it is higher than your original transaction, and manually edit the nonce to match the nonce of the transaction you want to replace.

Broadcasting this transaction should cause the original transaction with this nonce to show as dropped from the mempool.

Old Transactions

If you don’t mind waiting, the easiest thing to do is to just wait for you transaction to be dropped from the mempool. All Stacks nodes regularly clean up the mempool by dropping transactions that they first saw more than 256 blocks ago. That typically comes out to approximately around 2 days, so if you leave your stuck transaction for 2 days, then it should get dropped from the mempool and then you can reuse that nonce like normal.

Share this story