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?
Asked
Active
Viewed 2,857 times
5
2 Answers
3
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.
Asone
- 839
- 4
- 10
0
const isLocked = !(await ethereum._metamask.isUnlocked());
if (isLocked) {
window.location.reload()
}
// if not locked execute the rest of the logic
Yilmaz
- 1,580
- 10
- 24
web3.eth.coinbaseis notnull. – Anatoli Babenia Jun 16 '18 at 08:27