Access account

User accounts can be used in various contexts on Ethereum, including as identifiers and to sign transactions. In order to request a user's signature or have the user approve a transaction, the user's account must be accessible. The following wallet methods involve signing or transaction approval, both of which require sending accounts as a function parameter.

  • eth_sendTransaction

  • eth_sign(Not safe and not recommended)

  • eth_personalSign

  • eth_signTypedData

After connecting to the user, you can always recheck the current account with ethereum.selectedAddress. If you'd like to be notified when the address changes, we have an event you can subscribe to:

ethereum.on('accountsChanged', function (accounts) {
  // Time to reload your interface with accounts[0]!
});

If the first account in the returned array is not the one you expected, you should notify the user! In the future, the accounts array may contain multiple ones, but now not yet available. The first account in the array will always be considered the user's "selected" account.

Last updated