MetaMask / MetaMask/metamask-extension

Whenever I restart a local network like hardhat-network metamask do not detect changes and keep caching old nonces

Open
#12,211 13 comments 19 reactions 0 assignees View on GitHub
area-customNetworks area-devmode external-contributor INVALID-ISSUE-TEMPLATE Sev2-normal team-core-platform type-bug type-enhancement
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Describe the bug**
Whenever I restart a local network like hardhat-network metamask do not detect changes and keep caching old nonces.

**Steps to reproduce (REQUIRED)**

1. launch a network like hardhat via `hardhat node` (this will have chainId 31337)
2. add network to metamask where you specify http://localhost:8545 and chainId = 31337
3. make transaction via metamask on that network, this update the nonce of the account
4. repeat that for further accounts
5. stop the network and launch a new one (note that by default `hardhat node` will reuse the chainId (which is expected from a developer experience) but use a different genesisHash for block 0
6. Now you can perform another tx with metamask, but this will either silently fails or fails with an error because the nonce metamask use is the one cached from the previous network
7. In order to make metamask work with that new network, you have to click on settings -> advanced -> reset account and that for each account

**Expected behavior**
Metamask should be able to detect that the network changed (genesis Hash are different) and clear the cache when that happen
Alternatively Metamask should provide an api to request cache clear (does not need to clear the history if the network is the same as previous)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with `hardhat node` on chain ID 31337, make transactions in MetaMask, restart the network, and compare behavior with using Settings → Advanced → Reset account. Trace the network identity and account nonce caching behavior around the reused chain ID and changed genesis hash. Done means a restarted network is detected and stale nonce state is cleared without requiring a manual reset for each account.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.