Created
April 29, 2020 11:04
-
-
Save Vatsalya-singhi/971925111acb7d9757b9cba35d43a436 to your computer and use it in GitHub Desktop.
Request to access to user's accounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// request to access user account details | |
this.ethereum = (window as any).ethereum; | |
this.webby3 = (window as any).web3; | |
if (typeof this.ethereum == 'undefined') { | |
this.dialog.presentToast('Please install MetaMask extension'); | |
return; | |
} | |
try { | |
let x = await this.ethereum.enable(); | |
console.log('ethereum enabled=>', x); | |
}catch(err) { | |
console.log('err=>', err); | |
if (err.code == 4001) { | |
this.dialog.presentToast('User denied account access..'); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment