'eth_accounts' unexpectedly updated accounts

I’m using web3-react library to connect MetaMask.
Current problem is after connect once and then when MetaMask locked automatically, then trying connect again, show me console error with above text.

This error does not show when first connection, only show after locked automatically and retrying connect (button clicking in my dapp, then show unlock MetaMask popup, once fill the password, connect would be success, but in browser console, it show above error )
Why this is happening and how to solve it?
What cause this error?

FYI, I use
const signature = await provider?.getSigner().signMessage(messageToSign);
to implement user authentication, above error seems because above line. but not sure.

1 Like

Hello @BlackHorse !
Welcome to MetaMask community !

What version of the web3 library are you using?
Please check it in package.json file


Hello, @snwlprd.eth . Thank you for your reply. I’m using
@web3-react/core”: “8.0.35-beta.0”,
@web3-react/MetaMask”: “8.0.28-beta.0”,
@web3-react/types”: “8.0.20-beta.0”,
@web3-react/url”: “8.0.25-beta.0”,
@web3-react/walletconnect”: “8.0.35-beta.0”,


Can you show more code, especially the provider connection sections, and the context of using signature ?


@snwlprd.eth Here is what I’m trying:
In the authentication hook:

const { account, provider, connector } = useWeb3React();
const handleSignMessage = useCallback(async () => {
    try {
      if (!account || !provider || !connector) return;
      // Here The logic to generate messageToSign, and then next line is to get signature
      const signature = await provider?.getSigner().signMessage(messageToSign);

      // Node.js backend api call to get access token by sending signature as param. 
      // and then next  line is to store access token to localStorage
    } catch (e) {
      console.log('error ::', e);
    } finally {
  }, [account, provider, connector]);

Try rewriting your code like this.

 const signer = provider.getSigner()
 const signature = await signer.signMessage('some message');
1 Like

Same issue occurred.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.