When coding an application that looks to be metamask compatible how are multiple account handled by meta mask ? how can i make sure that metamask / my app are in sync account-wise ?

does metamask set the web3.eth.defaultAccount ?


According to Metamask's docs (https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md):

When a user selects an account in MetaMask, that account silently becomes the web3.eth.accounts[0] in your JS context, the only member of the web3.eth.accounts array.

So, by default, anytime you check for web3.eth.accounts[0] it will refer to the currently selected account in Metamask.


The user chooses web3.eth.defaultAccount, the option is not available to your web application. Although, you can query web3.eth.accounts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.