1

while building a Dapp using metamask to make transactions, i figured that metamask is not responding correctly when a transaction is spedup, making my code wait forever for a canceled transaction that will never finish.

example:

const contract = new Contract(abi, address);
await contract.methods.increaseAllowance(address, amount);
// metamask popup shows and i approve,then, while waiting for the Tx to get mined, i hit the speed up button and approve the speedup (sending a new transactions but with more gas)
console.log("allowance increased") // if the transaction is spedup, this code will never run, 

i can reproduce the issue multiple times, and it doesn't seem like metamask is aware of this. is there a way to fix this ? i don't see a way to listen on transaction speedup in their docs or at least a way to get teh new Tx hash to manually listen on it.

1 Answer 1

2
+50

There is one way of tracking this. Follow these steps.

  1. Fetch the nonce of the last transaction submitted by the account. In this case, the nonce of increaseAllowance called.
  2. Subscribe for pending transactions of the account.
  3. Check whether a new transaction is submitted with the same nonce. It will be the speed up transaction.

I think, for now this is the only possible way to catch a replacing transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.