MetaMask / MetaMask/metamask-extension
Extension ignores `TransactionRequest.nonce` passed from dapp
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
**Describe the bug**
I want to be able to initate transaction cancellation from inside the dapp. So I pass a transaction with `nonce = pendingTx.nonce` to `provider.sendTransaction`. But Metamask extension ignores it and uses its internally tracked nonce.
**Steps to reproduce (REQUIRED)**
1. Enable custom nonce in Metamask (optional, so you see what it uses)
2. Get a few txs pending, so we have legitimate nonces to cancel
3. In browser console
```js
let [acc] = await window.ethereum.enable()
// send 0 ETH from yourself to yourself, give it nonce of one of the pending txs
window.ethereum.request({method: "eth_sendTransaction", params:[{value: 0, to:acc, from:acc, nonce: '0x'+22..toString(16) }]})
```
4. In Metamask popup (and when executing tx) it still has its internal nonce
**Expected behavior**
Metamask uses what `nonce` dapp passes to it
**Browser details (please complete the following information):**
- OS: Ubuntu 20.04
- Browser: Chrome 96.0.4664.45
- MetaMask Version: 10.6.1
**Additional context (Error Messages, etc.)**
According to #2699 PR we should be able to specify nonce as long as it's not higher than latest confirmed nonce, so passing `nonce` of a pending transaction should work, but doesn't.
Contributor guide
Assessment
This issue has not been assessed yet.