Skip to content

Instantly share code, notes, and snippets.

@Vatsalya-singhi
Created April 29, 2020 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vatsalya-singhi/971925111acb7d9757b9cba35d43a436 to your computer and use it in GitHub Desktop.
Save Vatsalya-singhi/971925111acb7d9757b9cba35d43a436 to your computer and use it in GitHub Desktop.
Request to access to user's accounts
// 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