简体   繁体   中英

How to cancel a payment that awaits confirmation in Metamask using web3?

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: 在此处输入图像描述

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM