Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - expose multiple accounts to dapp #1648

Closed
vbaranov opened this issue Jun 21, 2017 · 9 comments
Closed

Feature - expose multiple accounts to dapp #1648

vbaranov opened this issue Jun 21, 2017 · 9 comments
Labels

Comments

@vbaranov
Copy link
Contributor

Is it possible to get the list of addresses from metamask chrome plugin into js?

I mean not accounts, that can be retrieved from RPC web3.eth.getAccounts(...).

But actually those addresses, which are listed in metamask plugin.

@tmashuang
Copy link
Contributor

Are you not able to get the address associated with your Metamask?

@vbaranov
Copy link
Contributor Author

I want to get the list of addresses from here:
screen shot 2017-06-21 at 15 53 36

and use this list in dapp to choose, for example, address that will be a sender of tx to contract.

@tmashuang
Copy link
Contributor

Ok, what does you code look like?

@vbaranov
Copy link
Contributor Author

function getWeb3(callback) {
  if (typeof window.web3 === 'undefined') {
    // no web3, use fallback
    console.error("Please use a web3 browser");
  } else {
    // window.web3 == web3 most of the time. Don't override the provided,
    // web3, just wrap it in your Web3.
    var myWeb3 = new Web3(window.web3.currentProvider); 

    // the default account doesn't seem to be persisted, copy it to our
    // new instance
    myWeb3.eth.defaultAccount = window.web3.eth.defaultAccount;

    callback(myWeb3);
  }
}

function startApp(web3) {
	//what should be here instead web3.eth.getAccounts to get the list of addresses from metamask plugin?
	web3.eth.getAccounts(function(error, accounts) {
		console.log(accounts);

		//further logic
	});
}


window.addEventListener('load', function() {
	getWeb3(startApp);
});

@tmashuang
Copy link
Contributor

Are you able to get the account that is selected or none?

@danfinlay
Copy link
Contributor

This is not currently supported by MetaMask, we only inject the selected account, so this is a feature request. I also think it's a duplicate, but can't check now.

@vbaranov
Copy link
Contributor Author

@tmashuang @FlySwatter thanks, sorry, if this is duplicate. I didn't find an original issue. It would be a nice feature.

@kumavis
Copy link
Member

kumavis commented Aug 17, 2017

relevant as its an overhaul of how accounts are exposed to dapps #537

@kumavis kumavis changed the title Retrieving of accounts' list from metamask Feature - expose multiple accounts to dapp Aug 17, 2017
@bdresser
Copy link
Contributor

Closing due to inactivity - if this is still a feature you're looking for, feel free to open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants