EIP-1102 account exposure opt-in approach (Opt-in account exposure)

No call decision · Security & privacy · EIP status Stagnant · created 2018-05-04

This EIP proposes the eth_requestAccounts approach, in which a wallet does not automatically give account information to a website, but instead only releases the account list once the user approves.

Why it is needed

Earlier generations of Ethereum-enabled browsers (wallets) injected the account list into a dapp without user consent. Because of this, a malicious website could view detailed account information simply from a user visiting the site, and there was also a risk of arbitrary transaction requests being sent without the user's consent. Even though most users would reject transaction requests from unfamiliar sites, a protocol was needed to prevent such requests from being possible in the first place. This EIP aims to solve this problem with a structure where account access must be explicitly requested by the dapp and approved by the user before accounts are exposed.

What changes

Today

After EIP-1102

Who is affected

In depth

eth_requestAccounts

Providers in Ethereum-enabled DOM environments define a new RPC method, eth_requestAccounts. It is called like ethereum.send('eth_requestAccounts'), and calling it may display a UI asking the user to approve or reject account access for a specific dapp. The return value is a Promise, which resolves to an array of accounts or rejects with an Error when accounts are unavailable.

Provider#enable (deprecated)

ethereum.enable() is the method used before eth_requestAccounts, and the source marks it as DEPRECATED. It similarly shows a user approval or rejection UI and returns a Promise, but the source recommends that new implementations use eth_requestAccounts instead.

Comparison of legacy and proposed initialization

In the legacy approach, if web3 was defined, the dapp simply continued execution. In the proposed approach, if a provider is defined, it first REQUESTs account access; if the user approves, it RESOLVEs with the accounts and the dapp continues, and if the user rejects, it REJECTs and the dapp halts. If no provider exists, the dapp halts in either case.

REQUEST, RESOLVE, REJECT rules

A dapp MUST request accounts by calling eth_requestAccounts on the provider exposed at window.ethereum. This call MAY display a user approval or rejection UI. The returned Promise MUST resolve with an array containing one or more accounts, or MUST reject if accounts are unavailable (e.g. the user rejects), in which case the error must contain informative details.

Constraints the browser must satisfy

The browser MUST expose a provider at window.ethereum and MUST define the eth_requestAccounts RPC method. This method may wait for user interaction before resolving or rejecting its Promise; when the Promise resolves it MUST contain one or more accounts, and if accounts are unavailable it MUST reject with an informative error.

Rationale for the proposal

The existing approach exposed accounts without user consent, allowing untrusted websites to view detailed account information or initiate arbitrary transactions. The source explains that even though most users would reject transaction requests from unfamiliar sites, such requests should not be possible in the first place. In the short term this allows hiding accounts from untrusted sites and blocking unnecessary transaction requests, and in the long term the source states it could extend to a structure where specific account information, identity information (uPort, DID), networks, and so on are selectively requested based on user consent.

Implementation status

According to the source, the MetaMask team implemented this strategy (MetaMask/metamask-extension PR #4703). However, this EIP's status is marked Stagnant, meaning activity has stopped with no further discussion or changes.

Original EIP · ← EIPs