I'm using MetaMask to make Ethereum transactions from my website, as described here: https://metamask.github.io/metamask-docs/Main_Concepts/Sending_Transactions

It works perfectly. I capture the transaction hash in the callback, then use it to track the transaction.

But I just noticed something; metamask has the option to "speed up" the transaction. I'm not sure exactly how it works, but this basically creates a new transaction with a larger gas price. However the callback is not called again.

I'm not sure exactly what it is doing. When I searched for the original transaction hash on an explorer, it doesn't exist. So they canceled it somehow?

I guess my problem is; how does my website know the original txhash is dead and receive the new txhash? How do people deal with this?

I also considered tracking the user transactions from the blockchain side, using subscribe to "Pending Transactions" function in web3, however this call cannot be filtered and so I get ALL pending transactions, not just transactions to my smart contract. This might be ok if I was running my own node, but I am using Infura. I would need to call Infura to get details on every pending transaction, probably they would ban me if I did that.

Does anyone have any insights?

  • Is it a contract execution or a transfer of ethers? Why do you need to keep track of transactions hashes? For contracts it is better to listen for events.
    – Ismael
    Sep 28 '19 at 17:53
  • Contract. Events are only fired when transactions are mined. I wanted to keep a track of the transaction while it is pending. Sep 29 '19 at 18:04
  • Why do you need to keep track of the pending transaction? A hash doesn't have any meaning and it can be replaced even after they were mined.
    – Ismael
    Sep 30 '19 at 3:09
  • The txhash does have meaning as it identifies the transaction. The txhash can be used to identify and retrieve the transaction details after it has been mined using services such as Infura. I don't understand what you mean when you say "a hash can be replaced after it has been mined" this is not true. the txhash is literally the hash of the transaction, it does not change. Sep 30 '19 at 9:27
  • In case of a chain reorg it is possible for a mined transaction to be replaced for a new one, so for some uses it is better to wait for confirmation a few blocks before trusting a transaction.
    – Ismael
    Sep 30 '19 at 12:58

To "speed up a transaction" there's only one possible option: to send a new transaction with higher gas price but with the same nonce. This way if nodes see both of the transactions they will most likely pick up the one with the higher gas price and once that is mined the other transaction becomes invalid (a tx with that nonce has already been mined) and is ignored & dropped.

Why you can't see the transaction hash of the second transaction is beyond me. It's a new transaction and should have a new transaction hash.

Some further reading on the topic: https://kb.myetherwallet.com/en/transactions/checking-or-replacing-a-tx-after-sending/

  • I can see the second transaction on the network, and it is mined perfectly. However the javascript callback is not executed a second time with that second txhash -- are you saying that it should? Sep 27 '19 at 18:40
  • 1
    sorry, I have no idea how that is supposed to work. Maybe such transactions are supposed to work with some other logic - that's up to MetaMask Sep 27 '19 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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