Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
1,296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. async function onInit() {
  2. await window.ethereum.enable();
  3.  
  4. web3.eth.getAccounts(function (error, accounts) {
  5. console.log(accounts[0], 'current account on init');
  6. });
  7.  
  8. // Acccounts now exposed
  9. window.ethereum.on('accountsChanged', function () {
  10. web3.eth.getAccounts(function (error, accounts) {
  11. console.log(accounts[0], 'current account after account change');
  12. });
  13. });
  14. }
  15. onInit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement