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
?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityWhen 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
.