4

I'm working on a crypto payment system using ethers Web3Provider

web3.eth.sendTransaction(transactionObject)

After the user calls this method, this dialog is shown: enter image description here

In the app the user is able to close the payment dialog leaving this pending. Is there a way to reject this payment using JS when closing the dialog inside the app? Clearing all payments would also be a solution but in the documentation I can't find anything about this case.

Edaurd B
  • 173
  • 1
  • 9
  • Hey! Have you found a way to solve this problem? I just have exactly the same situation now, I also need to cancel the pending transaction from js and close the Metamask popup. – Alexei Apr 22 '22 at 23:51
  • I am curious too – Najib Apr 23 '22 at 16:24
  • Nope, cause there is none. A metamask dev commented on another site about how this is imposibile cause of the way web3 works. – Edaurd B Apr 24 '22 at 10:01

1 Answers1

0

Here's an article that might help : https://chainstack.com/a-developers-guide-to-the-transactions-in-mempool-metamask-edition/

You can basically send a no eth transaction with a high fee and same account nounce as the pending transaction. This will help drop the pending transaction. This is how metamask "cancel" a transaction

LmnT
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 01 '22 at 18:58