Send nonce with send-tx to override a stuck transaction?

Hi. I have trouble in minting tokens on a ERC 20 contract.
While it was never an issue, suddenly all minting operations got in stuck and Etherscan shows me:

Estimated Confirmation Duration: ~ 14 hrs : 8 mins : 39 secs

Since the TokenSaleContract will be automatically get closed in 2 days, I have to rush in order to make all minting operations successful.

How can I bypass the pending transactions and submit new ones with more gas?

One thing I’ve read is to send a new transaction along with the same nonce than the pending transaction has. Would this be an option?

If yes, how can I do this with openzeppelin command line tools (oz send-tx --network main)?

Otherwise I think I have to do this with the Web3 SDK by myself, right?

Btw, why is my transaction suddenly in stuck with the gas-settings that have worked for me very good over the last 12 months? I send more Gas then USDT for example.

main: {
  provider: () => new HDWalletProvider(process.env.MAIN_MNEMONIC, "https://mainnet.infura.io/v3/" + infuraProjectId),
  network_id: 1,
  gas: 5000000,
  gasPrice: 20000000000
},

Many thanks for any hints and helpful statements.

1 Like

Hi @itinance,

Unfortunately for the past month or so there has been network congestion and high gas prices of 20-40 Gwei (see https://www.ethgasstation.info/) which is higher than the 20 Gwei gas price you used. This means that your transaction is stuck.

For a general guide on stuck transactions you can have a look at:

To resolve you can send another transaction with a higher gas price with the same nonce, miners should then pick up this transaction instead of the lower priced transaction.

This could be your original transaction or could be something else. I have previously transferred 0 ETH to myself, though you probably just want to send the mint transaction with the same nonce.

As far as I know we can’t use the CLI to specify the nonce, so you will have to write a script manually specifying the nonce to use for the transaction.

See Interacting Programmatically from the Learn guides for creating a script.

The following can help get you started, though you may want to change to resend the mint transaction:

// src/index.js
const Web3 = require('web3');

async function main() {
    // Set up web3 object, connected to the local development network
    const web3 = new Web3('http://localhost:8545');

    // Retrieve accounts from the local node
    const accounts = await web3.eth.getAccounts();

    const transactionCount = await web3.eth.getTransactionCount(accounts[0]);
    console.log(transactionCount);

    const transactionCountIncludingPending = await web3.eth.getTransactionCount(accounts[0], "pending");
    console.log(transactionCountIncludingPending);

    const tx = await web3.eth.sendTransaction({from:accounts[0],to:accounts[0], value:0, nonce:transactionCount});
    console.log(tx)
}

main();
1 Like

Hi @itinance,

Just wanted to check that you were able to get your transaction unstuck in time?

Many thanks for asking, @abcoathup!

Over night it went through and all other following transactions too. I raised Gasprice to 30 Gwei for newer transactions and they went through within 10 min. But the very last transaction needed about 3 hours, like the first ones,

What stands out here: all transactions, that needed more than 2 hours, were submittet at afternoon in CET. On 2 days they needed that much time. All other transactions, that was submittet early in the morning, went through within 10 min.

1 Like

Hi @itinance,

Gas prices are currently 65 Gwei. So I am glad there have been some quiet periods where 20Gwei transactions are getting picked up.

Nice to hear that it was resolved ok.

1 Like