MetaMask / MetaMask/metamask-extension

[Bug]: Can't handler account change

Open
#18,065 11 comments 0 reactions 0 assignees View on GitHub
devrel
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

### Describe the bug

Metamask is not able to detect account switching to the same website if the account is not connected.
That is, the value:
**window.ethereum.selectedAddress**
always maintains the last connected account
Which produces that I cannot update the value of the address in the events of the contracts to obtain
The same behavior can be observed for example in uniswap

I have two accounts, one connected and the other not, I change the account in metamask and the application after updating the page keeps the previous connected account and returns the values of the other account, not the current one

### Steps to reproduce

1. Two accounts
2. Left one of the two account conected to website
3. Change to another account without connected
4. The selectedAddress has not been changed

### Error messages or log output

_No response_

### Version

lasted

### Build type

None

### Browser

Chrome, Firefox, Brave

### Operating system

Windows

### Hardware wallet

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the account-switching flow with window.ethereum.selectedAddress: connect one account, switch to an unconnected account, and reload the site. Trace how the extension exposes the selected account and determine what behavior should make the value reflect the current account; done means the reported address updates reliably in this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, blockchain
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.