Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC1102, which proposes connection rules that improve privacy and security by withholding Ethereum account information from websites until users grant permission.

This article translates, summarizes, and supplements the material linked below. The original code comments remain in Japanese.

I have also covered various other EIPs.

Overview

ERC1102 defines a communication protocol for securely exchanging information between decentralized applications (dApps) and Ethereum-enabled DOM environments, such as browser extensions. Historically, Ethereum-enabled browsers automatically injected the user’s Ethereum accounts into the JavaScript environment when a page loaded. The new protocol is designed to withhold account information until the user explicitly consents to disclosure.

This mechanism improves user privacy and security, reducing the risk that malicious websites initiate unauthorized transactions or collect personal information.

Motivation

Earlier Ethereum-enabled browsers and extensions automatically exposed Ethereum accounts to web pages before obtaining the user’s permission. This created security risks: a website’s JavaScript could obtain account addresses or initiate unauthorized transactions without the user’s knowledge.

To address these risks, ERC1102 changes the protocol so that account information is exposed only after the user explicitly grants access. Users can therefore control when and to which dApps they disclose their account information.

By establishing a new standard for interaction between dApps and browsers, ERC1102 aims to provide a safer, more trustworthy Web3 experience.

Specification

The specification defines a communication protocol for exchanging account information between Ethereum-enabled browsers (such as MetaMask) and decentralized applications (dApps). It replaces automatic account injection with rules under which account information is disclosed only after explicit user authorization.

The eth_requestAccounts method

The eth_requestAccounts method provided by Ethereum-enabled browsers is a new way to request account access. When a dApp calls this method, the user is prompted to grant or deny access to their accounts. If the user grants access, the Promise resolves with an array of accounts. If access is denied, the Promise is rejected with an error.

javascript
const accounts = await ethereum.send('eth_requestAccounts');

This method makes explicit disclosure of account information at the user’s discretion possible, improving privacy and security.

Deprecation of provider.enable()

Previously, applications used the ethereum.enable() method. It is now deprecated in favor of eth_requestAccounts. Both have similar behavior, but eth_requestAccounts is defined as the explicit new standard.

Changes to the initialization protocol

Earlier dApps determined their behavior by checking whether web3 existed in the browser. However, this approach had security issues. Under the new initialization method proposed by ERC1102, a dApp accesses window.ethereum and explicitly requests account access. Account information is passed to the dApp only if the user grants permission.

The new initialization flow is as follows.

javascript
try {
  const accounts = await ethereum.send('eth_requestAccounts');
  // accounts[0]を使ってトランザクションなどを実行
  ethereum.send('eth_sendTransaction', { from: accounts[0], ... });
} catch (error) {
  // アクセス拒否された場合の処理
}

Requirements and constraints

Ethereum-enabled browsers implementing this specification must meet requirements such as the following.

  • The browser must expose a provider through window.ethereum.
  • It must implement the eth_requestAccounts method.
  • Promise resolution or rejection may wait for user interaction.
  • If no accounts can be provided, the Promise must be rejected with an error specifying the reason.
  • A successful Promise must include at least one account.

Additional considerations

Background and objectives

Historically, Ethereum-enabled browsers (DOM environments) commonly exposed user account information automatically as soon as a web page was opened. This design prioritized convenience, but it created significant privacy and security problems.

For example, an untrusted website could obtain a user’s Ethereum address without permission or initiate a transaction as though the user had requested it. Although many users would reject such unauthorized transactions, designing the system on the assumption that users can simply reject them does not provide fundamental protection.

ERC1102 addresses these problems at their source by requiring explicit user consent before account information is obtained.

Immediate benefits

With the introduction of this new protocol, users can do the following when interacting with untrusted websites.

  • Choose not to disclose account information.
  • Prevent unauthorized transaction requests by withholding their accounts.

This removes the risk of automatic access to account information by dApps and makes the Web3 user experience safer.

Future directions

The protocol is not limited to withholding account information. It could also be extended to selectively grant access to particular information or networks based on user consent.

Potential use cases include the following.

  • Explicitly authorize access to specific account information, such as uPort or DID information.
  • Allow users to respond to requests to connect to particular networks (for example, L2s).
  • Give users fine-grained control over the scope of information sharing according to the conditions they choose.

This would enable flexible information management based on user consent and is expected to make the Web3 user experience more sophisticated and secure.

Compatibility and migration impact

Introducing this protocol affects both dApp developers and developers of Ethereum-enabled browsers, including browser extensions.

On the dApp side, applications can no longer access account information automatically. Instead, they must explicitly request account access using eth_requestAccounts. On the browser side, implementations must control disclosure of account information based on user consent.

The proposal therefore encourages both dApps and browsers to adopt a new standard and lays a foundation for improving security across the Ethereum ecosystem.

References

Paul Bouchon mail@bitpshr.net, Erik Marks (@rekmarks), "EIP-1102: Opt-in account exposure [DRAFT]," Ethereum Improvement Proposals, no. 1102, May 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1102.

Conclusion

This article has covered ERC1102, which proposes connection rules that improve privacy and security by withholding Ethereum account information from websites until users grant permission.

What did you think?

If you have any questions, feel free to send me a direct message on Twitter.

Twitter @cardene777

I also publish on other platforms. Feel free to explore them.

https://chaldene.net/