I want to detect if my user unlock their metamask so I can redirect them to the right page as soon as they unlock instead of having them click away from the "your metamask is locked" page. Is that possible?
Web3js – Detect If MetaMask Was Just Unlocked
metamaskweb3js
Best Answer
If metamask is unlocked you should be able to call web3.eth.accounts.getAccounts() ( v 1.0.x ) to retrieve node's owned accounts or web3.eth.accounts with a non empty array node's owned account as result.